How can I save and restore the camera?

I’d like to restore the current view in skecthup to the way it was before my extension moved the camera around. I naively thought that this would work:

model = Sketchup.active_model
view = model.active_view
save_cam = view.camera
# do some stuff the changes the view
model.active_view.camera = save_cam

But it does not restore the view. I find I have to save the individual values for the camera, like eye, target, up, fov, etc. What am I missing?

You are right, you need to save these values…
Check also e.g. this post:

1 Like

Excellent, thanks.

save_cam = Sketchup::Camera.new(cam.eye, cam.target, cam.up, cam.perspective?, cam.fov)

works perfectly.