• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
blog.draftsperson.net

blog.draftsperson.net

the art of technical drawing

blog.draftsperson.net

DEEPCOUNT LISP: Count Blocks Including Nested Instances

August 3, 2026

An ordinary block count tells you how many block references sit in the drawing. That is not the same as how many of a component you actually have. DEEPCOUNT reports both, at any depth of nesting.

What DeepCount does

If a WORKSTATION block contains four CHAIR blocks and you have inserted ten workstations, you have ten primary blocks and forty chairs. Anyone ordering from the first figure is ordering thirty-six chairs short.

The routine counts both, with any number of instances at each level, and reports them under separate headings so the two figures cannot be confused for one another.

The report prints to the text window and can be written to a TXT or CSV file, which is opened automatically once written.

How to use it

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Type DEEPCOUNT.
  3. Read the report in the text window, or send it to a TXT or CSV file.
  4. Use the primary figure for what is placed on the sheet and the nested figure for what has to be ordered.

How it works

The nested count is computed from a map, not by walking the drawing repeatedly. A map is built once of which blocks contain which, and how many of each. Each primary block then walks that map, multiplying as it descends — so a block appearing three times inside a block that appears four times inside the one you inserted contributes twelve.

Dynamic blocks are counted under their real name. A dynamic block that has been modified is stored under an anonymous name like *U27. The effective name is recovered from its representation tag, so the count reads sensibly rather than listing dozens of *U entries that mean nothing to anybody.

Hidden nested blocks are not counted. A block marked invisible by DXF group 60 inside a definition is not present in the drawing as far as the user is concerned, and counting it would inflate the schedule — which is the same failure as undercounting, just in the more expensive direction.

Notes and limits

  • Read the right column. Primary is what is inserted; nested is what those insertions contain. Ordering from the wrong one is the whole problem this solves.
  • Anonymous dynamic block names are resolved to their real definitions.
  • Invisible nested blocks are excluded deliberately.
  • It only reads the drawing and changes nothing, so there is no undo group.

Download and details

NameDeepCount — count blocks, reporting primary and nested quantities separately
DownloadDeepCount.lsp — 14.2 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandDEEPCOUNT
Requiresthe ActiveX layer (loaded automatically by the routine with vl-load-com).
Source size14.2 KB, 363 lines
Error handlingYes — a *error* handler restores every system variable it changed, on cancel as well as on error.
UndoNot needed — this routine only reads the drawing and changes nothing.
CompatibilityAutoCAD (any release with AutoLISP), BricsCAD, ZWCAD, GstarCAD, ProgeCAD and other IntelliCAD-based platforms. AutoCAD LT needs a LISP enabler. No .NET, no ObjectARX, no installer.
AuthorYZ, August 2026
LicenceFree to use, supplied “as is” with no warranty.

References

  • BLOCKTALLY LISP — a full schedule as a table, CSV or text file
  • DEEPBURST LISP — take the nesting apart once you know what is in it
  • BLOCKPURGE LISP — remove blocks the count shows are not wanted
  • More free AutoLISP routines on this site
  • Wisey’s Steel Shapes — free structural steel section drawing program

Filed Under: AutoLISP Routines

Primary Sidebar

Subscribe to our Youtube Channel

Post CAD drafting jobs on Freelancer.com. and get some free money to do this.

Categories

  • American Steel Industry (4)
  • AutoCAD Articles & Reference (30)
  • AutoCAD Bugs & Problems (19)
  • AutoCAD Tips (29)
  • AutoCAD Tutorials (54)
  • AutoLISP Routines (328)
  • AutoLISP Tutorials (15)
  • CAD Standards (7)
  • Civil 3D (7)
  • Civil Drafting (4)
  • Dimensions (2)
  • Drafting Funnies (71)
  • Drafting History (9)
  • Drafting Standards (84)
  • Electrical Drafting (2)
  • General IT reference (7)
  • Geometry (15)
  • GIS (2)
  • Hatch Patterns (12)
  • Office Life Hacks (3)
  • PT (1)
  • Revit Tutorials (54)
  • Steel Detailing (14)
  • Structural Drafting (26)
  • Technical Dictionary (61)
  • Useful Website Links (19)

Footer

Free downloads

  • Free AutoLISP routines
  • Free hatch patterns
  • SHX fonts & text styles
  • Numbering LISP collection
  • ISO 3098B font

Reference charts

  • AWS weld symbols chart
  • Steel detailing chart
  • Hole & slot sizes
  • Bolt edge distance
  • ANSI & ARCH paper sizes
  • How to fold an A1 drawing

Useful links

  • CAD blocks (DWG)
  • Revit families
  • structuraldrafter.com
  • cad-corner.com
  • About
  • Privacy policy

Provided for free with no warranty · Log in