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):

5 1 vote
Article Rating
Subscribe
Notify of
guest

1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
blanchsb
3 years ago

Excellent post. I was looking how to do this and you got me over the hump.
Thanks.