Zoom Selection
- 
 @cadfather said: ok, this is what happens to the script: if i am inside of a group/component and 'hide rest of model' is on, zoom selection does not work. surely this must happen to everyone? You are correct, it does not work. There are 2 ways to zoom to a selection using the API and they both fail when "hide rest of model" is enabled. I'm not seeing a quick solution other than Matt's idea of temporarily switching 'hide rest' on, zooming, and then switching it off again. I'm sure a better "Zoom to Selection" could be written, though - one that would work in all configurations. 
- 
 Jim, you mean if a script was written from scratch it could be done? 
- 
 @cadfather said: Jim, you mean if a script was written from scratch it could be done? Yes, a camera zoom is simply moving the camera closer to the target, and can be done using Ruby. 
- 
 @jim said: … 
 a camera zoom is simply moving the camera closer to the target, and can be done using Ruby.Please, Jim, tell me how to move the camera to a selected item with distance of 2 meter by ruby script. 
- 
 model = Sketchup.active_model view = model.active_view camera = view.camera eye = camera.eye target = camera.target up = camera.up vector = target - eye vector.length = 2.m eye = eye + vector camera.set eye, target, up
- 
 Unbelievably, Jims code moves my model. Thank you very much. I have to play a lot, because I don’t understand, what the code makes. Repeating brings my model nearer and nearer. Change the unit from 2. to 2000. makes bigger steps. Change the unit from 2000. to -2000. turns the direction (the model goes remote). So, how can I see one part of my model with distance of 2 meters? 
- 
 I think if the last 4 lines are vector = eye - target vector.length = 2.m eye = target + vector camera.set eye, target, upthen you will get the desired result 
- 
 Sometimes RickWs code works pretty. But often it does not work. Then sometimes the error is: 
 @unknownuser said:Error: #<ArgumentError: (eval):197:in 'set': Eye and target points must be different> My goal is to select one item by name and to show this item with camera with distance 2 meters. 
- 
 @n lindenthal said: … 
 But often it does not work.
 …To make it work, I had to »Start Animation Observer«. @Rick 
 Your code works properly. Thank you very much.
- 
 @pixero said: @cadfather said: if i select something inside of a group it does not work - but will fit the contents to screen if nothing is selected. What do you mean with "It doesnt work" ? What do you want it to do? 
 If you are inside a group the group itself isn't selected.
 My script zooms in to whats selected. Inside group or not.Thx a lot! Great plugin. Work fine, no problem with selection zoom. 
 Can you recommend me any other useful plug?
Advertisement

 
                             
                             
                             
                             
                             
                             
                            