CADLisp Tools

Standards & QA

Drawing Layer Checker AutoLISP routine

Report objects on Layer 0 or Defpoints and list locked, frozen, or off layers. Download the .LSP source below and run the LAYERCHECK command after loading it.

⌘ LAYERCHECKv1.0.0IntermediateUpdated Sep 18, 2026

What it does

Drawing Layer Checker with the LAYERCHECK AutoLISP command

Performs a read-only layer hygiene scan and prints common review items without changing layer states or drawing objects.

AutoLISP command
LAYERCHECK
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 drawing-layer-checker.lsp AutoLISP code

drawing-layer-checker.lspAUTOLISP
;; CADLisp Tools - Drawing Layer Checker (read-only)
(defun ct-lc:layer-count (name / ss)
  (if (setq ss (ssget "_X" (list (cons 8 name)))) (sslength ss) 0))

(defun c:LAYERCHECK (/ color flags name row)
  (prompt (strcat "\nObjects on Layer 0 (all layouts): " (itoa (ct-lc:layer-count "0"))))
  (prompt (strcat "\nObjects on Defpoints (all layouts): " (itoa (ct-lc:layer-count "Defpoints"))))
  (prompt "\n--- Layers with special states ---")
  (setq row (tblnext "LAYER" T))
  (while row
    (setq name (cdr (assoc 2 row)) flags (cdr (assoc 70 row)) color (cdr (assoc 62 row)))
    (if (or (and color (< color 0))
            (/= 0 (logand flags 1))
            (/= 0 (logand flags 4))
            (/= 0 (logand flags 16)))
      (prompt (strcat "\n" name
        (if (and color (< color 0)) " [off]" "")
        (if (/= 0 (logand flags 1)) " [frozen]" "")
        (if (/= 0 (logand flags 4)) " [locked]" "")
        (if (/= 0 (logand flags 16)) " [xref-dependent]" ""))))
    (setq row (tblnext "LAYER")))
  (princ))

Setup

How to install the drawing-layer-checker.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 LAYERCHECK command

  1. 1Run LAYERCHECK.
  2. 2Review flagged object counts and layer states in command history.
  3. 3Make corrections manually under your standards.

Worked example

Example: Preflight a drawing before issue.

  1. Run LAYERCHECK.
  2. Review Layer 0/Defpoints counts and special states.
Expected result

Potential layer-hygiene issues are reported without edits.

Read before use

Notes and limitations

  • These checks are generic and do not encode company naming standards.
  • Some valid workflows intentionally use flagged states.
  • Not manually CAD-tested.

Version history

Changelog

v1.0.0Sep 18, 2026Initial read-only generic layer checks.

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 →
Drawing Cleanup6 disciplines

Purge/Audit Helper

Run CAD audit and one all-item purge pass only after explicit confirmation.

⌘ CLEANHELPIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Selection & Editing6 disciplines

Select Objects by Layer

Select objects on an existing named layer in the active model or paper-space layout.

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