I can’t figure out what is happening here:
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext as sc
surfaces = rs.GetObjects("sel all",rs.filter.surface)
names = []
for srf_ids in surfaces:
srf = rs.coercerhinoobject(srf_ids)
names.append(srf.Attributes.Name)
normalized_names = list(dict.fromkeys(names))
set_names = list(set(names))
print normalized_names
print len(normalized_names)
print set_names
print len(set_names)
""""""
for i in range(len(surfaces)):
for nm in normalized_names:
ps = []
for srf_ids in surfaces:
srf = rs.coercerhinoobject(srf_ids)
try:
tmp = srf.Attributes.Name
if tmp == nm:
ps.append(srf_ids)
except:
pass
ps_id = rs.JoinSurfaces(ps,True)
#ps_obj = rs.coercerhinoobject(ps_id)
rs.ObjectName(ps_id,nm)
I solved it:
I had to isolate the empty lists 
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext as sc
surfaces = rs.GetObjects("sel all",rs.filter.surface)
names = []
for srf_ids in surfaces:
srf = rs.coercerhinoobject(srf_ids)
names.append(srf.Attributes.Name)
normalized_names = list(dict.fromkeys(names))
#set_names = list(set(names))
#print normalized_names
#print len(normalized_names)
#print set_names
#print len(set_names)
""""""
for i in range(len(surfaces)):
for nm in normalized_names:
ps = []
for srf_ids in surfaces:
srf = rs.coercerhinoobject(srf_ids)
try:
tmp = srf.Attributes.Name
if tmp == nm:
ps.append(srf_ids)
except:
pass
#print ps
if len(ps) > 1:
ps_id = rs.JoinSurfaces(ps,True)
#ps_obj = rs.coercerhinoobject(ps_id)
rs.ObjectName(ps_id,nm)
1 Like
and thats how one can collect plenty of solutions 
I simply don’t stop trying even after I ask a question. I don’t accept defeat that easy.
1 Like
yes, that is generally a good attitude 