[HELP] How can i Batch delete layer and sublayer with object in it?

Rhino will push comfrim again an again.
Thanks

Lock the layers that you need.
Make sure there is nothing hidden and follow the next steps:

Use Select All command and delete the objects and then use the Purge command.
Purge command will delete all the empty layers. This way you can get rid of all the unncessary layers.

Cheers!

Thanks Anuj Modi

This is a good way, but I often have a lot of layers(maybe huge) with objects in them, maybe the status is locked, displayed, or not displayed, opened one by one, and the selection is also very cumbersome, is there any way to directly delete this layer and sublayer without any confirmation.

import rhinoscriptsyntax as rs
from scriptcontext import doc
names = rs.GetLayers()
for name in names:
    layer = doc.Layers.FindName(name)
    rhobjs = doc.Objects.FindByLayer(layer)
    for rhobj in rhobjs:
        doc.Objects.Remove(rhobj)
    doc.ActiveDoc.Layers.Remove(layer)
doc.Views.Redraw()

ForceDeleteLayers.py (310 Bytes)
1 Like