# zoom_selection.rb (C) Copyright 2006 jim.foltz@gmail.com # # Installs under the Camera menu. # Zooms in on selected entities, or zooms model extents if # nothing is selected. # # I use the 'z' key for zoom selection, and Shift-Z for zoom previous # # module JF def self.zoomSelection m = Sketchup.active_model v = m.active_view s = m.selection if ! s.empty? v = v.zoom s else v.zoom_extents end zoomOut(0.3) end # def self.zoom def self.zoomOut(a) m = Sketchup.active_model v = m.active_view c = v.camera t = c.target e = c.eye up = c.up v = t - e v.length = v.length * a c.set e-v, t, up end end #module JF sn = "zoom_selection.rb" unless file_loaded? sn UI.menu("Camera").add_item("Zoom Selection") { JF::zoomSelection } UI.menu("Camera").add_item("Zoom Out") { JF::zoomOut(2.0) } file_loaded sn end