Sketchup::InstancePath.persistent_id_path bug?

Here is a transcript from a ruby console session, with some comments. The model is attached. It is a component instance inside a group

model = Sketchup.active_model
#<Sketchup::Model:0x00000017512c20>
sel = model.selection
#<Sketchup::Selection:0x00000017089ca8>
g = sel[0] #after selecting the group
#<Sketchup::Group:0x0000000c1572f8>
c = sel[0] #after selecting the instance
#<Sketchup::ComponentInstance:0x0000000bdd6750>
g.persistent_id
4750
c.persistent_id
4749
ip = Sketchup::InstancePath.new([g, c])
#<Sketchup::InstancePath:0x0000000c156420>
ip.to_a
[#<Sketchup::Group:0x0000000c1572f8>, #<Sketchup::ComponentInstance:0x0000000bdd6750>]
ip.persistent_id_path
4750 # <<--- shoudld be 4750.4749
ip = Sketchup::InstancePath.new([g, c, c])
#<Sketchup::InstancePath:0x0000000c154cb0>
ip.persistent_id_path
4750.4749

So do I need to duplicate the last entity to get a valid path? Or append ‘.’ + c.persistent_id?

persistent_id.skp (134.1 KB)

Sorry, I now read the example to the end and saw persistent_id_path → String.
I cannot reproduce your example for nested groups. Are you sure your selections are nested?

I can reproduce the example. It is necessary before assigning variable “c” to go into edit mode on the group and select the component inside first.

As a side note, the group is non-standard, in that it contains a single entity, the component. I don’t know how to do that with the built-in tool set. (Clicking a single geometry object, and then right clicking it, results in a right click menu that does not include a group menu option). I suspect that the group was created with Ruby code.

I started from scratch with a new Sketchup drawing and drew a single rectangle and made it into a component. I then drew a single edge on top of the rectangle, which was not part of the component. After selecting both edge and component objects, I was able to group them as an outer group. I still encountered the same results. InstancePath is new for Sketchup 2017, and I’m not familiar with it.

I thought that perhaps being in edit mode resulted in a shortened path and active path has to be accounted for. I exited edit mode and still encountered the same results.

you can even group a single edge from the edit menu item…

john

1 Like

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