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.
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.
Sketchup.send_action( "viewFront:" )
Sketchup.send_action( "viewZoomExtents:" )
… or …
Sketchup.send_action( "viewZoomToSelection:" )
See the Team extension …
… or …
Thanks, Dan. I have completed what I need.
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.