0
$\begingroup$

I'm writing a script, that renders at some point. Currently I do it like this:

bpy.context.scene.render.filepath = os.path.join("C:/", filename) 
bpy.ops.render.render(animation=False, write_still=True, use_viewport=True)

It works, but blender will not respond while rendering. I tried using a new Thread, but then I get errors like:

E0426 11:06:03.478407 13256 path_trace.cpp:648] Error beginning GPUDisplay update.
E0426 11:06:05.722097 13256 path_trace_display.cpp:61] PathTraceDisplay implementation could 
not begin update.

and

Error: Render error (Permission denied) cannot save: 'C:\LS00.png'
Exception in thread Thread-2 (render_planets):
Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender 3.4\3.4\python\lib\threading.py", line 1016, 
in _bootstrap_inner
self.run()
File "C:\Program Files\Blender Foundation\Blender 3.4\3.4\python\lib\threading.py", line 953, 
in run
self._target(*self._args, **self._kwargs)
File "\Text", line 31, in render_planets
File "C:\Program Files\Blender Foundation\Blender 3.4\3.4\scripts\modules\bpy\ops.py", line 
113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Render error (Permission denied) cannot save: 'C:\LS00.png'

Is there a way, to render like it would, when you press F12? Blender stays responsive and there is a blue progressbar in the bottom?

Thanks for your help!

$\endgroup$

1 Answer 1

1
$\begingroup$

You can use 'INVOKE_DEFAULT' to make Blender render as if you pressed F12:

bpy.ops.render.render('INVOKE_DEFAULT')

However, rendering from a script is very tricky, since rendering is multithreaded and even happens on multiple devices it is hard for the script to know when it's done so if you have some other stuff that happens after you start rendering, it may behave in unexpected ways. You need to somehow wait until the rendering is done.

See How to wait the finish of the bpy.ops.render.render('INVOKE_DEFAULT',animation=False, write_still=True)?

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .