I’m using CopyObjects and find that they maintain their grouping with the original group or groups. I want an independent copy maintaining their grouping order but within their own independent groups.
I’m using Rhino 6 with python and willing to use Rhinoscript or Rhino Common.
I guess I would get the copied objects’ id’s once the copy is made and run RemoveFromAllGroups() on the copies, then create a new group with AddGroup() and add the copied objects to that with AddObjectsToGroup()…
The other thing you could do is go via RhinoCommon, get the base geometry of the objects to copy, then add the objects back to the document - they will not have any group associations in that case - and group them in a new group.
One of my problems is I have no control over how people group objects. Sometimes one, sometimes a series of nested groups. How would I maintain the grouping structure in the copy?
Can o’ worms… There is no good way to deal with this as not only can objects be in organized nested groups (like a tree), they can also be in overlapping groups and even grouped several times differently. I just don’t see an easy way to get that entire group structure and duplicate it independently. What I outlined should make a new independent ‘flat’ group. Maybe someone else has a better, more sophisticated way…
Thank you. Funny thing is if you copy the group in Rhino manually using ‘Copy’ it creates a unique and independent copy with the grouping structure intact. I could use the Command function and copy it this way but then I need all of the new id’s, which don’t get returned to me. I thought about using SelLast next but I’m nervous about doing it this way.
ids = rs.GetObjects("Select grouped objects", 0, True, True, True)
if ids:
rs.Command("_-Copy InPlace")
rs.UnselectAllObjects()
result = rs.LastCommandResult()
if result==0:
objs = rs.LastCreatedObjects(True)
else:
print "The command did not complete."