3D Viewport position

The position of the point from which we look at the scene in the 3D viewport area can be controlled through the Blender Python API. We can read the coordinates of this point and the direction of view from the viewport, and also set the values we need for them.

First, let’s get a pointer to the 3D viewport area:

Now we can get the coordinates of the origin of the viewport:

We got a vector from the 3D scene center, to the point from which we are looking at the scene.

We can also get the direction of the “look” from the viewport:

We got a quaternion from the center of the scene in the direction of view from the 3D viewport.

We can get the offset value of the viewport along its view direction:

And finally, we can set the values ​​for all these parameters ourselves to place the viewport in the position we need.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments