How to zoom viewport camera us…
Daz 3D Forums > Software > Daz Studio Discussion > Daz Script Developer Discussion>How to zoom viewport camera us…
How to zoom viewport camera using script?

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:
var viewMgr = MainWindow.getViewportMgr();var activeView = viewMgr.getActiveViewport();if ( activeView ) { var viewport3d = activeView.get3DViewport(); if ( viewport3d ) { var curCam = viewport3d.getCamera(); if ( curCam ) { ourCam.focalLength = desiredValue; } }}
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.