0
$\begingroup$

This code renders two images to files: default render (Render Active Scene, result is render0001.png) and viewport (result is opengl.png)

import bpy
bpy.context.scene.render.filepath = '//opengl'
bpy.ops.render.render()
bpy.ops.render.opengl(write_still=True)
print('Render Finished')

I want the .render() operator act like it was called from the interface (show progress bar, show render window in the end), so I add invoke context:

import bpy
bpy.context.scene.render.filepath = '//opengl'
bpy.ops.render.render('INVOKE_DEFAULT')
bpy.ops.render.opengl(write_still=True)
print('Render Finished')

however after adding this my second .opengl() doesn't produce an image. I still see Render Finished message in a console so the code executes, it's just the render that isn't fired.

If I switch places of .opengl() and .render(), I'm getting both images again. If I add 'INVOKE_DEFAULT' to .opengl(), I'm also getting both images, so I'm using this workaround at the moment. However I'd appreciate if someone could explain why adding 'INVOKE_DEFAULT' like in my second example blocks .opengl() from executing.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.