[Python] Finding objects with the same name

How can I find all objects with the same name and join them.
Assume multiple polysurfaces, to which names were assigned, were exploded.
How can I find all objects (separate surfaces) by name and join them.

I’ll manage joining but how can I find and sort them by names in separate lists?

Thanks in advance.

I’m thinking perhaps:

  • getting all objects’ names in a list
  • removing duplicates
  • use that list to get all objects with a name and join them.

You know what. I got the idea I’ll manage :smiley:

I would use a set to get all unique names, then create a dictionary of lists {name:[guid0,guid1,…]}
list(set(name_list)) will quickly get rid of duplicates

Or https://developer.rhino3d.com/samples/rhinocommon/find-objects-by-name/

1 Like

mylist=list(set(mylist)) and mylist = list(dict.fromkeys(mylist)) both worked

The question is now how to set the name of the joined polysurface to be the same as its sub-surfaces.

Name = rs.ObjectName(mysurf)
rs.ObjectName(mypolysurf, Name)

Awesome!

Thanks @Dancergraham,

1 Like