How to zoom viewport camera using script?
tshaq80_752a50b069
Posts: 35
What's the best way to programmatically zoom in the viewport camera (equivalent to manual viewport controls)?
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.