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
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
;; 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
- 1Download and review the source code.
- 2Load the .lsp file with APPLOAD in a copy of a drawing.
- 3Keep the routine session-only until it has been tested for your CAD version and standards.
Command workflow
How to run the LAYERCHECK command
- 1Run LAYERCHECK.
- 2Review flagged object counts and layer states in command history.
- 3Make corrections manually under your standards.
Worked example
Example: Preflight a drawing before issue.
- Run LAYERCHECK.
- Review Layer 0/Defpoints counts and special states.
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