How to pan the view to focus on some component


#1

i want to pan the current view to automatically focus on some component by the certain coord.


#2

Move the camera’s target to point at the new coord and move its eye to do the panning.


#3

Thank you. I’ll have a try


#4

Example:

# focus_on( component )
#
# @param component [Sketchup::ComponentInstance,Sketchup::Group]
# @return [Boolean]
def focus_on( component )
  return false unless component.respond_to?(:bounds)
  boundingbox = component.bounds
  target = boundingbox.center
  view   = Sketchup.active_model.active_view
  camera = view.camera
  camera.set( camera.eye, target, [0,0,1] )
  view.zoom( component )
  true
end

#5

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.