RecipesCount and measure
How do I count blocks by name in AutoCAD?
Type "count the blocks in this drawing by name, as a table". cadssistant selects every block reference, tallies them by block name in one AutoLISP pass and replies with a table of name and count; the table has Copy and Excel buttons. Nothing in the drawing changes. The same tally by hand is a loop over (ssget "_X" '((0 . "INSERT"))) reading group code 2 of each reference, shown below.
Checked 2026-10-30
count the blocks in this drawing by name, as a table
Paste it into the palette, or pick it from the recipes inside the chat.
What cadssistant does
- Selects every INSERT in the drawing with an ssget filter.
- Loops over the selection in one AutoLISP expression, reading the block name (group code 2) of each reference into a tally.
- Replies with a markdown table, one row per block name. Copy puts it on the clipboard as tab-separated text; Excel saves a CSV through AutoCAD's own save dialog.
The same task in AutoLISP
(progn
(setq ss (ssget "_X" '((0 . "INSERT"))) i 0 tally nil)
(if ss
(repeat (sslength ss)
(setq nm (cdr (assoc 2 (entget (ssname ss i)))) i (1+ i))
(setq tally
(if (assoc nm tally)
(subst (cons nm (1+ (cdr (assoc nm tally)))) (assoc nm tally) tally)
(cons (cons nm 1) tally)))))
tally)Returns (name . count) pairs; the chat turns the same list into the table.
Good to know
- Say "only on layer P-FIXT" or "only in the selection" to narrow it. For attributes as extra columns see Make a bill of materials from blocks.
More in count and measure
Command: CADSSISTANT
Works in AutoCAD 2024 and newer on Windows. Free trial, no card, no API key.
Get cadssistant