1

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.

chippwalters
  • 600
  • 3
  • 15
  • I thought it was bpy.ops.render.render(use_viewport=True) for an actual render and bpy.ops.render.opengl() for viewport render. – Christopher Bennett Jul 30 '21 at 00:10
  • Yes, both create a render, but they don't show the render in a new window, like the F12 button does. – chippwalters Jul 30 '21 at 01:21
  • 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. – Christopher Bennett Jul 30 '21 at 01:39

1 Answers1

1

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.

batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • 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? – chippwalters Jul 30 '21 at 22:01