I have some groups where their parent is a component and this component is repeated. Now I select a face in one of the groups in one of the components. How can I know the number of this component?
grp1 = face1.parent.instances
comp = grp1.parent.instances
I don’t know how to get #3?
Thank you in advance for your help.
The only way to know which of the instances the user has “drilled into”, is to get the active edit path:
It seems this method only works if we double click on a component to edit its geometry. I wish to click on a face and have the same information as active_path. Is it possible?
The InputPoint #instance_path method retrieves the instance path for the picked point.
@ip = Sketchup::InputPoint.new
def onMouseMove(flags, x, y, view)
@ip.pick(view, x, y)
@in_path = @ip.face ? @ip.instance_path : nil
if @in_path && @in_path.to_a.first.is_a?(Sketchup::ComponentInstance)
@ttip = @in_path.to_a.first.name
@ip.draw(view) if @ip.valid?
view.draw_points( @ip.position, 25, 3, "green" ) if @ip.valid?
view.tooltip = @ttip
view.draw_text([10,10], @in_path.to_a.join("\n")) if @in_path
This indicates you are writing a Tool. The first post only said you had a selected face.
Please be more specific. @dezmo has given you the Tool answer.
You are great. “@ip.instance_path.to_a” solve my problem.