How to delete objects in a certain layer which is hidden?

How do I delete all the objects on a certain layer which is hidden by code?

You could try the open source Python DelAll component from here: (39.5 KB)

import rhinoscriptsyntax as rs
import scriptcontext as sc
from Rhino import RhinoDoc

if (delete):
        sc.doc = RhinoDoc.ActiveDoc
        for aLayer in layer:
            if rs.IsLayer(aLayer):
                objects = rs.ObjectsByLayer(aLayer, False)
                if (objects and len(objects) > 0):
                    print('{0} deleted [{1}]'.format(len(objects), aLayer))
    finally: #restore original Grasshopper document as default
        sc.doc = ghdoc
1 Like