Identifying an Entity (Group) with a Tool (InputPoint or PickHelper)

I am trying to determine the top level group (wall assembly) with my “Add Window” tool as I mouse over it. I know this is probably a very easy piece of code but as I look at the documentation for the InputPoint Class I can’t seem to find the correct method to use to accomplish this. Should I be trying to use the PickHelper Class instead?

This code should point you in the correct direction. Also, onMouseMove might be called many times a second so keep things streamlined.

# save time later by caching the reference to the pick helper for the active_view
# when you create the tool

def activate
  @ph = Sketchup.active_model.active_view.pick_helper
  .
  .
  .
 end


 def onMouseMove(flags, x, y, view)
   @ph.do_pick(x, y)
   my_object = @ph.best_picked
   
  # handle adding or removing my_object from the selection array
  Sketchup.active_model.selection.add(my_object)

end
2 Likes

Just a FYI for general readership:

2 Likes

Thank-you, I think I have a better grasp of the PickHelper now, that is the route I will go with.

1 Like

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