How do I script LAYER operations in batch?


Three layer jobs come up again and again on the forum, and all three are scriptable through Hurricane: clearing junk layer filters, selecting everything on one layer, and setting layer states (on/off/freeze/lock) across many drawings.

Set layer states with -LAYER

-LAYER is the no-dialog version of the Layer command. Its options cover everything a script needs — Make, Set, New, On, OFf, Freeze, Thaw, LOck, Unlock, COlor, and more. For example, to freeze a layer and turn another off:

-LAYER
F                ; Freeze
DEFPOINTS        ; layer name (wildcards allowed, e.g. XREF*)
OFF
DIM*             ; turn off every layer starting with DIM
               ; (Enter) exit the command

Delete ALL layer filters (without stalling the script)

Inherited drawings often carry dozens of nested layer filters that clutter the Layer Manager. The catch: most "delete filters" routines prompt, and a prompt stalls an unattended batch. The Hurricane forum hosts a no-prompt version that just removes them all:

Get the routine: delfiltersall.lsp from Delete all Layer Filters on the Hurricane Forum — a script-safe build that deletes every layer filter with no questions asked.

Select all objects on a specific layer

There's no native command-line "select by layer", but the classic SSX (Selection Set by example) routine does it, and is handy inside scripts. The forum has a copy since Autodesk dropped it after R14:

Get the routine: SSX.zip from Selecting by layer in a script (SSX). A no-LISP workaround also works: -LAYER Lock every layer except the target, then SELECT ALL — locked layers are skipped.
💬 From the Hurricane Forum: Delete all Layer Filters (script-safe) · Select objects by layer in a script (SSX) · Import / create layers from a text file

Related


PreviousBack to Hurricane for Autodesk® AutoCAD® - FAQNext