[Bug] Groups in ComponentInstances made unique
-
I know that if you edit a group copy via the API it affects all copies, but I've not found anyone describing this related problem:
Scenario:
You have a Component Instance (
Comp1)
Inside that component there's a group (Group1ofGroupDef1)
You make a copy of the Component Instance (Comp2)
Then you makeComp2uniqueGroup1 inside
Comp2is still a copy ofGroupDef1You open
Comp2and edit the group inside, now it's made uniqueGroup2ofGroupDef2
However, via the API, Group2.entities.parent still refer toGroupDef1
What's more,GroupDef1.instancesdoes not refer toGroup2So while SU create a new definition when you edit
Group2, the back-reference ofGroup2.entities.parentis not.The only work around I've found is
group.make_unique if not group.entities.parent.instances.include?(group). All though, this will break any group/copy links of group instances that actually is identical. So it's not ideal. -
I think this would be a non-destructive workaround:
def get_real_parent(group) Sketchup.active_model.definitions.each { |d| return d if d.group? && d.instances.include?(group) } end group_parent = ( group.entities.parent.instances.include?(group) ) ? group.entities.parent ; get_real_parent(group)Next time the model is loaded the mixed up
.parentreferences is corrected. -
thnx for the workaround,
haven't tried it yet tho.... but gj
Advertisement