AutoCAD Batch Scripting Cheat Sheet
Everything you need to script AutoCAD reliably across many drawings - the commands, the system variables to set first, sample scripts, and the gotchas that trip people up. Print it, save it, share it.
What a script is
A script (.scr) is a plain-text file of commands, exactly as you would type them at the AutoCAD command line, run top to bottom. A space or a new line = pressing Enter. Run one with SCRIPT (or -SCRIPT for no dialog).
The golden rule
Use the command-line versions of commands so nothing pops up a dialog mid-run. Most have a hyphen form: -PLOT, -PURGE, -INSERT, -LAYER. And turn off file dialogs entirely with FILEDIA 0.
System variables to set first
Set these at the top so commands run silently and never stop for a prompt:
| Variable | Set to | Why |
|---|---|---|
FILEDIA | 0 | Suppresses open/save file dialogs so commands take typed paths |
CMDDIA | 0 | Suppresses command dialogs (e.g. plot) |
CMDECHO | 0 | Stops command echo - cleaner and faster |
EXPERT | 5 | Suppresses "are you sure?" prompts that would stall the batch |
ATTREQ / ATTDIA | 0 | No attribute prompts or dialogs on inserts |
BACKGROUNDPLOT | 0 | Plot in the foreground so the script waits for each plot to finish |
Reset them at the end (e.g. FILEDIA 1) if you want the UI back to normal afterward.
The two lines people forget
Every drawing in a batch must be opened and saved. In a raw script that means OPEN … and QSAVE. The smarter approach: let a batch tool handle open and save for you, so your script is only the change you want - not the file plumbing. (Hurricane does this automatically.)
Sample scripts
Zoom Extents + Save (clean-up / refresh)
FILEDIA 0
CMDECHO 0
ZOOM E
QSAVE
Purge everything (twice, to catch nested) + audit
-PURGE A * N
-PURGE A * N
AUDIT Y
QSAVE
Set a layer current and freeze another
-LAYER S MyLayer F OldLayer
QSAVE
Common gotchas
- A blank line in a script = an Enter, which repeats the last command. Watch for stray blank lines.
- Trailing spaces at the end of a line also act as an Enter - invisible bugs.
- Commands that open dialogs (no hyphen form, with FILEDIA on) will hang the batch.
- Test on copies first - always.
- AutoCAD versions occasionally change prompt order; test one drawing before running 500.
The faster way
Hand-writing scripts is fine for simple jobs. For title-block updates, search-and-replace, batch plotting, renaming, or purging across hundreds of drawings, a tool that builds the script for you and runs it across the whole set saves the scripting and the babysitting.
Skip the scripting - let Hurricane build it
Batch plot, edit & automate AutoCAD in 3 clicks, no LISP. Free trial, no time limit.
Download Free Trial Buy Now - $149/seatMore references: AutoCAD Command Reference | System Variable Reference | Hurricane Features