Switching to the view from camera throug the python API

To switch to the view from the active camera we can execute the following command:

This operator works in the toggle mode, so the next executing of the same command returns the view to the previous state.

We can switch to the camera view without using operators from bpy.ops.

The following code switch to the camera view for the first “3D View” window:

And for all windows:

If we need to switch to the camera view for the current window (for the certain context):

Nikita

Author: Nikita

Blender add-ons developer and articles writer.