Automation, Performance & Collaboration - From AutoLISP to Autodesk Docs

AutoCAD · AutoLISP & Automation

Overview

If you repeat the same task over and over, you can automate it with AutoLISP, macros, and scripts.

Add cleanup commands like PURGE/AUDIT/OVERKILL to keep drawings lean, and collaboration features like Autodesk Docs, Trace, and Share to sync with your team — individual productivity improves 2–3x, and team workflow improves by a factor of several.

> For basic shortcuts and editing commands, see 01-shortcuts.md. For block/Xref operations, see 03-blocks-xref.md.


1. AutoLISP — AutoCAD's Built-in Scripting Language

AutoLISP has been bundled with AutoCAD since 1986 and is a LISP-derived language. Extensions: .lsp (source), .fas/.vlx (compiled).

1.1 How to Load

MethodDescription
APPLOADSelect file via dialog
(load "C:/my.lsp")Direct load from the command line
Startup SuiteAPPLOAD → Contents → register in auto-load list
acaddoc.lspRuns every time any drawing opens
acad.lspRuns once at AutoCAD startup
Tip Don't dump all personal/team utilities into acaddoc.lsp — registering them individually in the Startup Suite is better for version control and debugging.

1.2 Basic Structure — Hello World

(defun c:HELLO ()
  (princ "\nHello, AutoCAD!")
  (princ)
)
  • defun: Function definition.
  • c: prefix: makes the function callable as HELLO from the command line.
  • princ: output function. The trailing (princ) is a conventional call that suppresses the return value (nil) from being echoed at the command line.

1.3 Commonly Used Built-in Functions

FunctionPurpose
getpointGet a point coordinate from the user
getdistGet a distance (two points or a number)
getreal / getintReal or integer input
getstringString input
getangle / getorientAngle input
entselSelect a single object
ssgetBuild a selection set (supports filters)
commandCall a built-in AutoCAD command
entget / entmodRead/write DXF data of an entity
assoc / cons / substManipulate association lists
mapcar / foreachIterate through lists

1.4 Practical Routine Example — "Lock Layers of Selected Objects"

(defun c:LL ( / ss i ent lay)
  (princ "\nSelect objects to lock their layers: ")
  (setq ss (ssget))
  (if ss
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (setq lay (cdr (assoc 8 (entget ent))))
      (command "_.LAYER" "_LO" lay "")
    )
  )
  (princ)
)

After loading, type LL at the command line and the layers of the selected objects will all be locked. The key point is that DXF code 8 holds the layer name of an entity.

1.5 Visual LISP, COM, .NET

  • VLIDE: Visual LISP integrated development environment. Includes debugger and console.
  • After (vl-load-com), you can manipulate the ActiveX object model via the (vla-*) family of functions — a more powerful form of automation.
  • .NET (C#/VB): Load DLLs with NETLOAD to deploy in-house tools. This is the domain of professional developers.
  • ObjectARX: C++ based. The standard development environment for third-party plug-ins.
Tip A typical user doesn't need to go as far as .NET. Just loading 10 of your coworker's .lsp files via acaddoc.lsp can double your perceived productivity.

2. Command Macros

In the CUI "Macro" field, write a command sequence as a string and bind it to a toolbar, ribbon button, or keyboard shortcut.

2.1 Syntax

SymbolMeaning
^C^CTwo Esc presses (cancel any running command)
_Underscore — force English command (multilingual environments)
.Ignore user redefinition and use the default command
; or newlineEnter
\Pause for user input
*Repeat the command itself

2.2 Examples

Switch current layer to DIMS, then start linear dimensioning:

^C^C_-LAYER;S;DIMS;;_DIMLINEAR

Insert company-standard block TB-A3 at the paper space origin:

^C^C_-INSERT;TB-A3;0,0;1;1;0
Tip Prefix a macro with * to make the command auto-repeat. Useful for continuous insertion or continuous annotation.

3. SCR Scripts & Batch Execution

3.1 SCR Files

An .scr file is a plain text file listing command-line input one line at a time.

ZOOM EXTENTS
PURGE ALL * N
AUDIT Y
QSAVE

Load and run with the SCRIPT command, or pass it with the /b option when launching AutoCAD.

3.2 Batch Processing Many DWGs

  • ScriptPro 2.0 (free from Autodesk): pair an SCR with a DWG list for batch execution.
  • accoreconsole.exe (AutoCAD 2013+): opens DWGs and runs SCRs in the background with no GUI. The standard way to process thousands of DWGs overnight on a server.
Tip Running a weekly maintenance SCR (AUDIT → -PURGE A * N → SAVE) against every DWG prevents file bloat and early signs of corruption.
Note If a dialog pops up inside the SCR (with FILEDIA=1), automation halts. Switch to non-dialog mode at the start of the script with FILEDIA 0 and CMDDIA 0, and always restore them at the end.

4. Performance Optimization — Keeping Drawings Lean

4.1 PURGE

PURGE (PU) removes unused definitions (layers, blocks, linetypes, text styles, dimension styles, materials, etc.).

OptionDescription
Default dialogSelect items via checkboxes
-PURGECommand-line version for automation
-PURGE RClean up Registered Applications (Regapps)
Purge nested itemsPurge blocks inside blocks
Purge zero-length geometryZero-length lines, empty text
Tip If a definition can't be purged in one pass, it's still referenced inside another definition. Running -PURGE A * N 2–3 times usually cleans it up.

4.2 AUDIT / RECOVER / RECOVERALL

  • AUDIT: Integrity check on the current drawing. Answer "Fix errors? Y" for automatic repair.
  • RECOVER: Opens a corrupted DWG in recovery mode. Use for files that won't open with plain OPEN.
  • RECOVERALL: Recovers the current DWG and all Xrefs together.
Tip When a DWG won't open, the order is (1) a viewer like DWG TrueView → (2) RECOVER → (3) restore the .bak file → (4) autosave .sv$ (SAVEFILEPATH) → (5) commercial recovery services.

4.3 OVERKILL

OVERKILL consolidates duplicate objects stacked on the same spot and collinear segmented lines into single entities.

  • Filters by layer, color, linetype.
  • Numeric fuzz (tolerance): treats slightly offset objects as identical.
  • Optimize polylines: simplifies consecutive straight segments.
  • Combine co-linear objects: merges collinear objects.
Tip Output from PDF→DWG conversion or scan tracing can contain thousands of overlapping lines. OVERKILL is your top-priority cleanup tool.

4.4 Recommended System Variable Values

VariableDefaultRecommendedDescription
SAVETIME105Autosave interval (minutes)
ISAVEBAK11Create .bak backup
INDEXCTL03Optimize partial Xref loading
WHIPTHREAD13Multi-threaded display
VTENABLE150Disable zoom/pan animation (speed up)
BACKGROUNDPLOT20–2For large Publish jobs, 0 is safest

4.5 Troubleshooting Large Drawings

SymptomLikely CauseAction
Slow openMany Xrefs, huge imagesRaise INDEXCTL, lower image resolution
Slow saveDrawing History enabledTurn History off, -PURGE
Laggy selectionDuplicate objectsOVERKILL
Slow hatchDense patternsIncrease scale, switch to Solid, send to back
Long REGENToo many objectsFreeze unused layers, VP Freeze
Plot hangsBACKGROUNDPLOTSet to 0, lower PDF quality

5. Collaboration — Autodesk Docs, AutoCAD Web, Share, Trace

5.1 Autodesk Docs / Construction Cloud

  • Shared project file repository. DWG/PDF review, markup, and release management are unified.
  • Open and save directly from AutoCAD via Open from Autodesk Docs / Save to Autodesk Docs.
  • Versions, permissions, and activity logs are recorded automatically.
Tip Compared to traditional stores like Windows shares or SharePoint, its strength is built-in drawing locking and version history. For teams of 5 or more, the switch is well worth recommending.

5.2 AutoCAD Web / Mobile

  • From browser or tablet: open DWGs, make simple edits, measure, and annotate.
  • Great for on-site quick checks and markups. Do full editing on the desktop.

5.3 SHARE — Link Sharing

SHARE turns the current drawing into a link that opens in Autodesk Viewer. Recipients can view it just from the URL, no install required. The default expiration is 7 days.

5.4 Drawing History / COMPARE / XCOMPARE

  • For DWGs in versioned stores like Autodesk Docs, Drawing History lets you compare past versions via a slider.
  • COMPARE / XCOMPARE: Overlay differences between two DWGs in color.

5.5 Trace (2022+)

TRACE lets you overlay annotations and edit proposals on a semi-transparent layer without modifying the original drawing.

A Trace created on web or mobile can be loaded on desktop to review and merge.

Markup Assist: Uses AI to recognize PDF/image markups and proposes converting them into editable objects on the Trace layer.

5.6 Markup Import (2023+, improved in 2026)

MARKUPIMPORT inserts an external PDF, PNG, or JPG markup as a Trace layer.

Starting in 2026, it syncs bidirectionally with Autodesk Docs — markups edited in Docs are reflected back into AutoCAD automatically.

5.7 eTransmit — The Standard for External Distribution

ETRANSMIT bundles the current DWG along with all Xrefs, images, SHX/TTF fonts, and plot styles into a single ZIP or folder.

Plain file copying tends to miss references and fonts, so for outsourcing, inspection, and bid submissions, always use eTransmit.

5.8 Trusted DWG

A DWG created or saved by genuine, Autodesk-certified applications. Opening a DWG saved by another CAD tool may trigger a "Not a Trusted DWG" warning.

Functionally there is little difference, but to avoid assembly or compatibility incidents we recommend opening important drawings in AutoCAD and saving them once.


6. Collaboration Infrastructure — Standard Deployment

  • DWS + CHECKSTANDARDS: Standards checking against corporate or national standards.
  • Sheet Set: consistent project sheet management (see 03-blocks-xref.md for details).
  • Block Library / networked Tool Palette: same blocks for everyone.
  • CUIx Partial deployment: identical ribbon, shortcuts, and macros for all.
  • Profile (.arg): sync OPTIONS settings via export/import.
Tip To automate new-hire setup, include in the login script (1) Profile import, (2) template path mapping, and (3) registering in-house LSPs in the Startup Suite.

7. Field Checklist

  • Frequently used LSPs are registered in the Startup Suite
  • acaddoc.lsp is kept from bloating
  • In-house standard macros are deployed via Partial CUIx
  • Overnight batch processing is based on accoreconsole.exe
  • A weekly maintenance SCR (AUDIT→PURGE→SAVE) is running
  • SAVETIME=5, ISAVEBAK=1 are enabled for autosave and backup
  • INDEXCTL=3 is applied on large Xrefs
  • OVERKILL is applied to scan and PDF→DWG output
  • External submissions are packaged with ETRANSMIT
  • Autodesk Docs or an equivalent VCS is the team repository
  • Markup Import / Trace workflows are shared with the team
  • Profile .arg is used for new-hire setup

Bookmark this site!
PC: Ctrl + D
Mobile: Browser menu → Add bookmark