1
$\begingroup$

I know I can call bpy.ops.render.opengl() and that will create the render, but what I want to do is to create and then view the render, just like what happens when you use the View > Viewport Render Image menu item. Is there a way to do this?

So, to ask another way, how can I call the render window (F11) via python? F11 Hides or shows the render window.

$\endgroup$
3
  • $\begingroup$ I thought it was bpy.ops.render.render(use_viewport=True) for an actual render and bpy.ops.render.opengl() for viewport render. $\endgroup$ Commented Jul 30, 2021 at 0:10
  • $\begingroup$ Yes, both create a render, but they don't show the render in a new window, like the F12 button does. $\endgroup$ Commented Jul 30, 2021 at 1:21
  • $\begingroup$ Yeah, that's a little deeper than I'm comfortable advising on, given my limited experience with blender python. Do you need to call on the window manager? I'll upvote the question and hopefully send it into someone else's more capable hands. $\endgroup$ Commented Jul 30, 2021 at 1:39

1 Answer 1

1
$\begingroup$

Invoke the operator.

When called from the UI an operator is "invoked" with "default" settings. To do same from script bpy.ops.foo.bar('INVOKE_DEFAULT')

What do different execution contexts mean?

From python console,

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

does the "UI thing" and opens the render window (if that's your setting)

whereas

>>> bpy.ops.render.opengl()
{'FINISHED'}

executes the operator.

$\endgroup$
1
  • $\begingroup$ While that works, all code beneath that (where I reset the viewport props) is executed before the render. Whereas if I don't use INVOKE_DEFAULT, the code is executed in the correct order. Can I use a timer or something to make sure the code is executed after? $\endgroup$ Commented Jul 30, 2021 at 22:01

You must log in to answer this question.

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