3
$\begingroup$

When I use the Set Render Region via the search menu, I instantly get the setting where I can set the region with mouseclicks, but when I run the following code

import bpy

#override context, only to run command from text editor:
override_context = bpy.context.copy()
area = [area for area in bpy.context.screen.areas if area.type == "VIEW_3D"][0]
override_context['window'] = bpy.context.window
override_context['screen'] = bpy.context.screen
override_context['area'] = area
override_context['region'] = area.regions[-1]
override_context['scene'] = bpy.context.scene
override_context['space_data'] = area.spaces.active

bpy.ops.view3d.render_border(override_context, wait_for_input=True)

nothing happens. I dont want to hardcode the borders, I want it to work exactly like when I use the Set Render Region command from the search menu.

$\endgroup$

1 Answer 1

4
$\begingroup$

EXEC_DEFAULT is used by default, running only the execute() method, but you may want the operator to take user interaction with INVOKE_DEFAULT which will also call invoke() if existing:

bpy.ops.view3d.render_border(override_context,'INVOKE_DEFAULT', wait_for_input=True)

https://docs.blender.org/api/current/bpy.ops.html

BTW, You can use new context override method, which makes code a little bit clear:

import bpy
from bpy import context

area = [area for area in bpy.context.screen.areas if area.type == "VIEW_3D"][0]

with context.temp_override(area=area, region=area.regions[-1]):
    bpy.ops.view3d.render_border('INVOKE_DEFAULT', wait_for_input=True) 
$\endgroup$

You must log in to answer this question.

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