Steve, is correct. If any of your scene’s cameras switch to parallel projection you might need to restore the camera’s perspective. For simplicity, I only showed the main 3: eye, target and up vector.
But the Camera#set method only takes the 3 main arguments.
To set the 2 two that Steve mentions.
Example 1 saving properties in an array:
cam = Sketchup.active_model.active_view.camera
@cam_props = [cam.eye, cam.target, cam.up, cam.height, cam.perspective?]
… later …
cam = Sketchup.active_model.active_view.camera.set(*@cam_props[0..2])
cam.perspective= @cam_props[4]
cam.height= @cam_props[3] if !cam.perspective?
For example 2, where we save the whole camera object, …
the Camera class constructor takes additional optional arguments.
cam = Sketchup.active_model.active_view.camera
if cam.perspective?
@old_cam = Sketchup::Camera.new(
cam.eye, cam.target, cam.up, cam.perspective?, cam.fov
)
else
@old_cam = Sketchup::Camera.new(
cam.eye, cam.target, cam.up, cam.perspective?
)
end
@old_height = cam.perspective? ? nil : cam.height
… later …
cam = Sketchup.active_model.active_view.camera= @old_cam
cam.height= @old_height if !cam.perspective? && @old_height
Also, the reason I showed saving as instance vars is that I don’t know whether your iterate scenes and the camera restoration are done in the same method or separated into various methods.
If it is all in the same method, then you can omit the @s and just use local variables.