Zoom in on object
-
I want to be able to zoom in on an object - by rotating the camera and changing the field of view, rather than moving the camera like the standard zoom area does. Does anyone have this in a ruby anywhere already?
Often when you use Zoom Area in SketchUp, the object you were trying to zoom on is no longer visible. If you were to zoom by changing the FOV, then the object would still be visible - just larger.
The attached image shows what happens when I use the standard Zoom Area to zoom in on the sconce on the left wall.
We have used Sketchup.active_model.active_view.zoom(Sketchup.active_model.selection) with the same results.
-
Have you tried
Sketchup.send_action("viewZoomToSelection:")
?
It should work cross-platform. -
@tig said:
Have you tried
Sketchup.send_action("viewZoomToSelection:")
?
It should work cross-platform.I just tried it - it works just the same as Sketchup.active_model.active_view.zoom(Sketchup.active_model.selection) and moves the camera over next to the wall, and you cannot see the object on the wall.
The right solution will point the camera at the selected object, without moving the eye itself, and then adjust the FOV so that the selected object is zoomed in on from the same camera position as the original view. We can write it and post it here on SketchUcation. But if someone else has already written it, it would save us some time.
-
[These quotes are from a private message which was sent to me]
@unknownuser said:
@unknownuser said:
The right solution will point the camera at the selected object, without moving the eye itself, and then adjust the FOV so that the selected object is zoomed in on from the same camera position as the original view. We can write it and post it here on SketchUcation. But if someone else has already written it, it would save us some time.
Are you sure that's what you want?
I don't want to change the guy's FOV at all, it stays changed, then he has to reset it to get back to what he uses.
I just want to zoom to the selection w/o changing the FOV and then back the eye out a little.
I wonder why Zoom to Selection does not do this already?
But it is a good idea. You should be able to move the camera along a line from the eye to the target, and you should be able to calculate just how far to move it by measuring the selected object in the current view.
On the other hand, I don't mind changing the FOV as much as you do, as long as the user is smart enough to use view previous to return.
Perhaps we can make that an option.
I got to thinking that perhaps the problem with the current zoom to selection was that it was preserving my Front View, so I changed to a non-named view by rotating a bit. Still when I selected an object, (the rectangle), on the left wall and right clicked to "Zoom Extents", it still moved the camera to the left rather than moving it towards the selected object and placed the camera on the wrong side of the wall.
-
Don't you want to 'align the view to face' [or similar] first, before using 'zoom-selection'... BUT of course if the object[s] selected are 3d, then which face is going to be chosen for that alignment ???
-
@tig said:
Don't you want to 'align the view to face' [or similar] first, before using 'zoom-selection'... BUT of course if the object[s] selected are 3d, then which face is going to be chosen for that alignment ???
Here is one method.
This is the original view with Susan selected.
If I use SketchUp Zoom to Selection, the camera is moved left and the selection is no longer visible.
However, if I first point the camera at the selection and then zoom to selection it works pretty well.
So, for the function I want I just need to move the target of the camera to the center of the selection before using Zoom to Selection
-
Here is the code which makes this work.
If points to the center of the first item in the selection set,
then uses SketchUp zoom to selection to do the zoom.It zooms to the third, desired, image in the post previous to this one.
def zoom_selection # zoom to selection by rotating camera first model = Sketchup.active_model entity = model.selection[0] if (!entity) do_error("Nothing selected") return end#if view = model.active_view camera = view.camera eye = camera.eye target = camera.target up = camera.up target = entity.bounds.center camera.set(eye, target, up) # point to selection view.zoom(model.selection) # then zoom end#def
Advertisement