I would like to change the 3d viewport to orthogonal from a python script. From the key mapping I found this command "view3d.view_persportho". I always find it tricky when I have to mess with the context (Which I think is nescesary). Anyway, I tried this:
for area in bpy.context.window.screen.areas:
if area.type == 'VIEW_3D':
for region in area.regions:
if region.type == 'WINDOW':
override = bpy.context.copy()
override['area'] = area
override['region'] = region
override['scene'] = bpy.context.scene
bpy.ops.wm.setup_ui(override)
# Maybe I can set perspective here somehow?
class MYOP_setup_ui(bpy.types.Operator):
bl_idname = "wm.setup_ui"
bl_label = "Setup UI"
def execute(self, context):
context.space_data.show_region_ui = True # This opens the sidebar panels correctly
# I know that I can't pass arguments to operators like in the next line.
# bpy.ops.view3d.view_persportho('ORTHO') # 'PERSP', 'CAMERA'
return {'FINISHED'}
I found these, which is pretty much what I want, but I can't get it to work. Maybe pre 2.8?