Issue with rs.HideObject()

Why does this work:

def TST():
    objs=[obj for obj in rs.AllObjects() if rs.IsObjectSelectable(obj)]
    for obj in objs:
        rs.HideObject(obj)

But this doesn’t:

def TST1():
    for l in sc.doc.Layers:
        objs = rs.ObjectsByLayer(l.Name)
        for obj in objs:
            #print obj
            rs.HideObject(obj)

Works here…

@Helvetosaur,

Do you have sub-layers with objects in them?

Yep, as I suspected.

It doesn’t require the name of the layer but its fullpath.

The information inside the documentation is wrong when the context is a sub-layer.

This now works:

def TST1():
    for l in sc.doc.Layers:
        objs = rs.ObjectsByLayer(l.FullPath)#.Name
        for obj in objs:
            print obj
            rs.HideObject(obj)