Hi all. I wonder if there is a quick ruby code could do the flowing steps:
Set the front view of an active model.
Then align the model’s center to screen center.
Last, zoom out or in the camera to fit the model into a fixed square region(ex.1024*1024) in the center of the screen.
The better result is that it could save the current view into a png file.
From:
To:
Thanks for your time.
That is the way of thinking when a human user does it.
The way you would do it with the API is to use math to calculate the desired camera position/direction/field of view in one step and apply it in one step.
dezmo
March 18, 2019, 3:25pm
3
jeremyliu1989:
Set the front view of an active model.
Sketchup.send_action( "viewFront:" )
jeremyliu1989:
Then align the model’s center to screen center.
Either …
Sketchup.send_action( "viewZoomExtents:" )
… or …
Sketchup.send_action( "viewZoomToSelection:" )
See the Team extension …
http://extensions.sketchup.com/en/content/safe-frames
… or …
Sketchup::View#zoom()
method
Sketchup::View#write_image()
method
Thanks, Dan. I have completed what I need.
1 Like
Thanks, dezmo. I wanna write it by myself, coz it’s really quick code…
Yes, for step 3, need to do some math calculation. Thanks for your advice, and I have completed this.