CADLisp Tools

Selection & Editing

Select Objects by Layer AutoLISP routine

Select objects on an existing named layer in the active model or paper-space layout. Download the .LSP source below and run the SELBYLAYER command after loading it.

⌘ SELBYLAYERv1.1.0BeginnerUpdated Sep 18, 2026

What it does

Select Objects by Layer with the SELBYLAYER AutoLISP command

Builds an active-layout selection set from an exact layer name so the result can be inspected or passed to the next CAD command without mixing model and paper-space objects.

AutoLISP command
SELBYLAYER
Difficulty
Beginner

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 select-objects-by-layer.lsp AutoLISP code

select-objects-by-layer.lspAUTOLISP
;; CADLisp Tools - Select Objects by Layer
(defun c:SELBYLAYER (/ layer ss)
  (setq layer (getstring T "\nExisting layer name: "))
  (cond
    ((= layer "") (prompt "\nLayer name cannot be blank."))
    ((null (tblsearch "LAYER" layer)) (prompt "\nLayer not found."))
    ((setq ss (ssget "_X" (list (cons 8 layer) (cons 410 (getvar "CTAB")))))
      (sssetfirst nil ss)
      (prompt (strcat "\nSelected " (itoa (sslength ss))
                      " object(s) in the current layout.")))
    (T (prompt "\nNo objects found on that layer in the current layout.")))
  (princ))

Setup

How to install the select-objects-by-layer.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 SELBYLAYER command

  1. 1Run SELBYLAYER.
  2. 2Enter an exact existing layer name.
  3. 3Continue with another command using the highlighted active-layout selection.

Worked example

Example: Select all objects on ANNO-TEXT in the active layout.

  1. Run SELBYLAYER.
  2. Enter ANNO-TEXT.
  3. Inspect the highlighted set.
Expected result

Objects matching that layer in the current layout are selected.

Read before use

Notes and limitations

  • Uses an exact case-insensitive layer-name match.
  • Does not select matching objects from other layouts or nested block/xref content.
  • Objects on locked layers can be selected but may not be editable.
  • Not manually CAD-tested.

Version history

Changelog

v1.1.0Sep 18, 2026Limit the result to the current layout and handle blank or empty results explicitly.
v1.0.0Sep 18, 2026Initial layer-filter routine.

Keep automating

Related tools

Layers6 disciplines

Assign Selection to Existing Layer

Move selected objects onto an existing layer with validation and no layer creation.

⌘ TOLAYERBeginnerCAD support: not tested
Updated Sep 12, 2026VIEW TOOL →
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

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 →