Say I have an InstancePath pointing to a specific face in a specific subgroup. I would like to change, say, the material on that face. The face might be in a group whose definition is currently shared with other groups. This is an internal optimization; for the user, what should occur is that only one face is changed, the one in the specific group mentioned in the InstancePath. The answer appears to be “call the
#make_unique method on the Group object”. Right, but that method makes the InstancePath invalid! Try:
f = grp1.entities # my face inside 'grp1', which is not unique path1 = Sketchup::InstancePath.new [grp1, f] path1.valid? # true grp1.make_unique path1.valid? # false!
The reason is clear: the face
f is a member of the original
entities collection, but
#make_unique created a new
grp1.definition with a new copy of the whole
entities collection. So the InstancePath
[grp1, f] is no longer valid now. What is the fix? I can think about horrible hacks like finding the index of
f.parent.entities, and locating the face at the same index inside the new
grp1.definition.entities; does that even work reliably?