How to zoom viewport camera using script?
![tshaq80_752a50b069](https://secure.gravatar.com/avatar/31b6a70ff5b14a1558f2f75450706777?&r=pg&s=100&d=https%3A%2F%2Fvanillicon.com%2F31b6a70ff5b14a1558f2f75450706777_100.png)
What's the best way to programmatically zoom in the viewport camera (equivalent to manual viewport controls)?
You currently have no notifications.
What's the best way to programmatically zoom in the viewport camera (equivalent to manual viewport controls)?
Licensing Agreement | Terms of Service | Privacy Policy | EULA
© 2025 Daz Productions Inc. All Rights Reserved.
Comments
Assuming you want to zoom (i.e. adjust teh focal length) then this would work, I think:
If you want to dolly the camera you'd have to get its facing (maybe getFocalPoint(), which returns a vector), I think, then use that as a vector to add to its x,y,z position.
Thanks for the response. Is there a way to do this while keeping focal length constant? When I zoom in viewport, that doesn't change the focal length
Have a look at this post: 87636/a-script-to-control-a-selected-property-with-large-font-size-and-preview-buttons
The "View" Tab of that dialog has controls to:
The script attached to that post contains the relevant source code, which is quite well commented.