Group for objects having the same name obj


i want make a group for objects having the same name obj
one group/ one obj (with the same name obj)

help me

How about just adding this to your code inside your loop - after rs.SetUserText()…


autolabel (2.8 KB)
4_try count group by obj name.3dm (637.3 KB)

tnx but i dont understand where im broken the step

sorry i’m a beginner
@Helvetosaur tnx
your code is ok but dont make a group whit more of one obj whit the same name obj
tnx infinitely

autolabel (2.8 KB)
new try count group by more obj name.3dm (167.4 KB)

OK, I thought that was what you wanted…

I’ll have a look later if I have time…

i love you

Bbbbuut… you don’t even know me…! :stuck_out_tongue_winking_eye:

Let me see if I can clarify your need here - you have a series of objects which have object names, and some of the objects have the same name as other objects… You would like to create as many groups as there unique object names, and have all the same-named objects go into the same group - which has the same name as the object(s).

Did I get that right?


1 Like

all objects with the same name are in the same group.
each set of objects with the same name creates a group.
many sets, many groups.
Thank you very much.

Not sure how to interpret your script, but a solution to the description might be this:

import rhinoscriptsyntax as rs

def grouped_by_name():
    objs = rs.GetObjects()
    if not objs: return
    #collect names of all objects
    all_names = [rs.ObjectName(obj) for obj in objs]
    #reate a list from a set, the set will contain only unique items
    unique_names = list(set(all_names))
    #cull a possible None value for objects that had no name
    true_names = [name for name in unique_names if not name == None]
    for group_name in true_names:
        named_objects = [obj for obj in objs if rs.ObjectName(obj) == group_name]
        rs.AddObjectsToGroup(named_objects, group_name)
if __name__=="__main__":



Thanks Willem, that’s pretty much what I was going to suggest, just stuck here running lasers this afternoon, not much time.


cazzo fortissimo,tnx
you are great @Willem and @Helvetosaur.
is perfect for me
molte grazie