1
$\begingroup$

With this code fragment, I can enter the camera view correctly, but I'd like to be able to get out.

 for a in bpy.context.screen.areas: 
        if a.type == 'VIEW_3D': 
            for r in a.regions: 
                if r.type == 'WINDOW': 
                    override = {'window': bpy.context.window,
                                'area': a, 
                                'region': r,
                                'scene': bpy.context.scene,
                                'active_object': camera}
                    bpy.ops.view3d.object_as_camera(override)
$\endgroup$
3
  • $\begingroup$ uh, is it important that you use python to exit? this can be done easily with a keyboard shortcut. $\endgroup$
    – Millard
    Sep 29, 2019 at 17:22
  • $\begingroup$ @Millard it is not very important, but it is necessary to understand $\endgroup$
    – Noob Cat
    Sep 29, 2019 at 17:28
  • 1
    $\begingroup$ I was just making sure you wanted a python answer. I'm not sure how to do this in python, was just making sure you knew it could be done with a shortcut. lol. $\endgroup$
    – Millard
    Sep 29, 2019 at 17:30

1 Answer 1

1
$\begingroup$

You can use the view3d.viewnumpad operation.
Pass on the override context, just like in your example code. This snippet can also be used to enter the active camera's view.

bpy.ops.view3d.viewnumpad(override, type='CAMERA')
$\endgroup$

You must log in to answer this question.

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