Convert component to group

NO !
You are missing a vital point.

group = entities.add_group()

safely makes an empty group in ANY entities context.
You can then add objects into that group.entities context.

entities.add_group(entities_ary)

will only work if the entities reference is pointing to the model.active_entities.
It cannot point at some other entities context - even if the array of entities is in the same entities context as your new group…
You will get BugSplats.


How about this less risky approach ?
entities = inst.parent.entities
group = entities.add_group()
temp = group.entities.add_instance(inst.definition, inst.transformation)
group.layer = inst.layer
group.material = inst.material
group.locked = inst.locked?
group.hidden = inst.hidden?
### perhaps copy over attribute dictionaries too ?
inst.erase!
temp.explode
2 Likes