Seems to be more or less OK. I don’t get the “System GUID at…” here though when I print, just the name.
You can shorten your script considerably though (unless you want the intermediate results as well):
import rhinoscriptsyntax as rs
all_objs = rs.AllObjects()
layernames = set()
for obj in all_objs:
if rs.IsObjectHidden(obj): layernames.add(rs.ObjectLayer(obj))
for layername in layernames: print layername
print "No hidden objects found!"
Why did I use
set() for the layer names instead of a list
? Well, if you have multiple objects hidden on the same layer, each object adds the same name to the list, so you will print the layer multiple times. Unlike a list, a set in Python is composed only of unique members, so there will be only one instance of a layer name in there even if multiple objects are hidden on the same layer. On the other hand a set is “unordered” so you cannot depend on the order the layer names will be printed like you might with a list.