[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 (Group1
ofGroupDef1
)
You make a copy of the Component Instance (Comp2
)
Then you makeComp2
uniqueGroup1 inside
Comp2
is still a copy ofGroupDef1
You open
Comp2
and edit the group inside, now it's made uniqueGroup2
ofGroupDef2
However, via the API, Group2.entities.parent still refer toGroupDef1
What's more,GroupDef1.instances
does not refer toGroup2
So while SU create a new definition when you edit
Group2
, the back-reference ofGroup2.entities.parent
is 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
.parent
references is corrected. -
thnx for the workaround,
haven't tried it yet tho.... but gj
Advertisement