CADLisp Tools

Drawing Cleanup

Purge/Audit Helper AutoLISP routine

Run CAD audit and one all-item purge pass only after explicit confirmation. Download the .LSP source below and run the CLEANHELP command after loading it.

⌘ CLEANHELPv1.1.0IntermediateUpdated Sep 18, 2026

What it does

Purge/Audit Helper with the CLEANHELP AutoLISP command

Wraps the host CAD application's AUDIT and command-line PURGE workflows behind a clear confirmation prompt and grouped undo request for drawing cleanup.

AutoLISP command
CLEANHELP
Difficulty
Intermediate

Applicable disciplines

CAD workflows that use this routine

Requirements and compatibility

What it needs

AutoLISP

Software rows marked “Not tested” are not compatibility claims. Test the routine in a copy of your drawing and CAD version.

Downloadable source code

Review the purge-audit-helper.lsp AutoLISP code

purge-audit-helper.lspAUTOLISP
;; CADLisp Tools - Purge/Audit Helper
(defun c:CLEANHELP (/ *error* answer undo-started)
  (defun *error* (message)
    (if undo-started (command-s "_.UNDO" "_End"))
    (if (and message (not (wcmatch (strcase message) "*CANCEL*,*QUIT*,*EXIT*")))
      (prompt (strcat "\nCLEANHELP stopped: " message)))
    (princ))
  (initget "Yes No")
  (setq answer (getkword "\nRun AUDIT and all-item PURGE? [Yes/No] <No>: "))
  (if (= answer "Yes")
    (progn
      (if (= 0 (logand 8 (getvar "UNDOCTL")))
        (progn (command-s "_.UNDO" "_Begin") (setq undo-started T)))
      (command-s "_.AUDIT" "_Yes")
      (command-s "_.-PURGE" "_All" "*" "_No")
      (if undo-started (progn (command-s "_.UNDO" "_End") (setq undo-started nil)))
      (prompt "\nAudit and purge commands completed. Review command history."))
    (prompt "\nCleanup cancelled."))
  (princ))

Setup

How to install the purge-audit-helper.lsp file

  1. 1Download and review the source code.
  2. 2Load the .lsp file with APPLOAD in a copy of a drawing.
  3. 3Keep the routine session-only until it has been tested for your CAD version and standards.

Command workflow

How to run the CLEANHELP command

  1. 1Save a copy of the drawing.
  2. 2Run CLEANHELP.
  3. 3Type Yes to run AUDIT and one all-item PURGE pass.

Worked example

Example: Clean a copied drawing before transmittal.

  1. Save a backup.
  2. Run CLEANHELP.
  3. Confirm and review command history.
Expected result

The host commands audit and purge eligible unused definitions once.

Read before use

Notes and limitations

  • Built-in command prompts can differ across CAD products and versions.
  • Purged definitions or audit repairs may not be fully recoverable in every host even when an undo group is requested; keep a backup.
  • Not manually CAD-tested.

Version history

Changelog

v1.1.0Sep 18, 2026Use command-s, error cleanup, explicit one-pass behavior, and grouped undo request.
v1.0.0Sep 18, 2026Initial confirmation-gated cleanup wrapper.

Keep automating

Related tools

Drawing Cleanup6 disciplines

Delete Empty Layers

Preview and optionally delete unused, non-protected layers.

⌘ DELEMPTYAdvancedCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Standards & QA6 disciplines

Detect Duplicate Text

Select duplicate TEXT or MTEXT at matching insertion points.

⌘ DUPTEXTIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Standards & QA6 disciplines

Drawing Layer Checker

Report objects on Layer 0 or Defpoints and list locked, frozen, or off layers.

⌘ LAYERCHECKIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →