CADLisp Tools

Blocks & Attributes

Select Same Blocks AutoLISP routine

Select same-name block references, including dynamic block references. Download the .LSP source below and run the SELSAMEBLOCKS command after loading it.

⌘ SELSAMEBLOCKSv1.1.0IntermediateUpdated Sep 18, 2026

What it does

Select Same Blocks with the SELSAMEBLOCKS AutoLISP command

Uses one picked block as the pattern and highlights matching INSERT entities in the current model or paper-space layout, resolving dynamic-block effective names through ActiveX.

AutoLISP command
SELSAMEBLOCKS
Difficulty
Intermediate

Applicable disciplines

CAD workflows that use this routine

Requirements and compatibility

What it needs

AutoLISPVisual LISPActiveX

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-same-blocks.lsp AutoLISP code

select-same-blocks.lspAUTOLISP
;; CADLisp Tools - Select Same Blocks
(vl-load-com)

(defun ct-sb:name (ent / data obj result)
  (setq data (and ent (entget ent)))
  (if data
    (progn
      (setq obj (vl-catch-all-apply 'vlax-ename->vla-object (list ent)))
      (if (not (vl-catch-all-error-p obj))
        (progn
          (if (vlax-property-available-p obj 'EffectiveName)
            (setq result (vl-catch-all-apply 'vla-get-EffectiveName (list obj))))
          (if (or (null result) (vl-catch-all-error-p result))
            (setq result (vl-catch-all-apply 'vla-get-Name (list obj))))))
      (if (or (null result) (vl-catch-all-error-p result))
        (setq result (cdr (assoc 2 data))))
      result)))

(defun c:SELSAMEBLOCKS (/ all data ent i name out pick test-name)
  (cond
    ((null (setq pick (entsel "\nPick a block reference: ")))
      (prompt "\nNo object selected."))
    ((or (null (setq data (entget (car pick))))
         (/= (cdr (assoc 0 data)) "INSERT"))
      (prompt "\nThe selected object is not a block reference."))
    ((null (setq name (ct-sb:name (car pick))))
      (prompt "\nThe block name could not be read."))
    (T
      (setq out (ssadd)
            all (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar "CTAB")))))
      (if all
        (progn
          (setq i 0)
          (repeat (sslength all)
            (setq ent (ssname all i) test-name (ct-sb:name ent))
            (if (and test-name (= (strcase test-name) (strcase name))) (ssadd ent out))
            (setq i (1+ i)))))
      (sssetfirst nil out)
      (prompt (strcat "\nSelected " (itoa (sslength out))
                      " matching block(s) in the current layout."))))
  (princ))

Setup

How to install the select-same-blocks.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 SELSAMEBLOCKS command

  1. 1Run SELSAMEBLOCKS.
  2. 2Pick a block reference.
  3. 3Review the matching references highlighted in the current layout.

Worked example

Example: Select every instance of a door-symbol block.

  1. Run SELSAMEBLOCKS.
  2. Pick one door symbol.
  3. Review the selection.
Expected result

References with the same effective block name in the current layout are selected.

Read before use

Notes and limitations

  • Does not inspect nested blocks.
  • Requires ActiveX to resolve dynamic-block effective names.
  • Not manually CAD-tested.

Version history

Changelog

v1.1.0Sep 18, 2026Resolve dynamic-block names and limit selection to the active layout.
v1.0.0Sep 18, 2026Initial stored-name selector.

Keep automating

Related tools

Data Extraction4 disciplines

BOM from Block Attributes

Count selected blocks by one chosen attribute value.

⌘ BLOCKBOMAdvancedCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Blocks & Attributes6 disciplines

Count Selected Blocks

Summarize selected block references by name in the command line.

⌘ COUNTBLOCKSIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Data Extraction6 disciplines

Export Block Attributes to CSV

Export selected block names and attribute tag/value pairs to a CSV file.

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