• 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

Block Count LISP Routine (BC.LSP) for AutoCAD

September 18, 2020

Last updated July 27, 2026

Block Count is a compact AutoLISP routine that tallies how many times each of your chosen blocks appears in the current drawing, then writes the totals out to a plain text file. According to the header in the source file, it was written by Gary Annable in May 1991 and freely donated to the Public Domain Software Market, which makes it one of the older utilities in our library and one of the easiest to understand.

It suits anyone who needs a quick quantity take-off of repeated symbols — valves, light fittings, furniture, section markers — without setting up AutoCAD’s data extraction tools. You tell it which block names you care about, run one command, and read the counts from the report file it leaves behind.

What it does in practice

The routine works from two lists. First it scans the drawing’s block table and gathers the name of every block defined in the file. Then it opens a text file called BLKTXT — a list you prepare beforehand, one block name per line — and reads in the names you actually want counted.

For each name that appears on both lists, BC steps through every entity in the drawing and counts the ones whose name field matches, which in practice means each insertion of that block is tallied. While it works, the command line shows “Counting blocks .” and prints a further dot for each block it processes, so you can see it has not stalled.

The results are not shown on screen. Instead the routine writes a report file named after the current drawing with a .TMP extension, in the folder AutoCAD is working from. Each line holds the block name — trimmed to eight characters, a habit from the DOS era it was written in — followed by the count.

One quirk worth knowing: because the match is made on the entity’s name field, an attribute whose tag happens to be identical to a listed block name will also be added to that block’s count. If you use attributed blocks, keep the tag names distinct from the block names on your list.

Command reference

The file defines a single command, BC, which counts the blocks listed in your BLKTXT file and writes the totals to the drawing-name .TMP report. There are no options or settings, and no prompts to answer.

How to load it

Extract BC.LSP from the BLC.zip download, then type APPLOAD in AutoCAD, browse to the file and click Load. If you plan to use it regularly, add it to the Startup Suite in the same dialog so it loads with every drawing session. For more background on loading and managing LISP files, see our AutoLISP programming guide.

Step-by-step usage

  • Create a plain text file named BLKTXT — no extension — with one block name per line, typed exactly as the blocks are named in the drawing (the comparison is case-sensitive). The original convention was to finish the list with a line reading EOF, and the code still recognises it, though simply ending the file works too.
  • Save BLKTXT in the current working folder. The routine opens the file by name alone, so it will not be found via AutoCAD’s support file search path. The .TMP report lands in the same folder, which is a handy way to confirm where that is.
  • Load BC.LSP and type BC at the command line.
  • Watch for “Counting blocks .” followed by a dot per block. When the dots stop, it is done.
  • Open the report — the drawing name with .TMP added — in Notepad or any text editor.

Note that the routine has no error handling. If BLKTXT cannot be found it stops with an AutoLISP error rather than a friendly message, so check the file name and its location first if that happens. If you are curious how the file reading and writing is done, BC.LSP is a tidy real-world example of the techniques covered in Lesson 10 of our AutoLISP series, Input and Output.

Compatibility notes

This is pure AutoLISP — no DCL dialog files and no Express Tools functions — so nothing in it demands full AutoCAD. It should load on any full AutoCAD release, and in principle on AutoCAD LT 2024 or later, which added AutoLISP support. See what runs on AutoCAD LT for the details.

It was written for 1991-era AutoCAD, and two age-related quirks show. On current releases the DWGNAME system variable includes the .dwg extension, so expect the report to be named along the lines of Plan.dwg.TMP. And block names longer than eight characters are truncated in the report, although they are still counted correctly.

Download

Name: Block Count
Description: Program to count specific blocks in a drawing.
Type: AutoCAD AutoLISP Routine
Author: Anon
File Size: 2 Kb
Cost: Free
Worked on: AutoCAD
Download File: BLC.zip

Related routines

  • Block Rename — a free routine for renaming blocks in a drawing.
  • WBlock All — writes blocks out of a drawing to separate files.
  • FixBlock — another free block utility from the routine library.

References

  • AutoLISP programming guide
  • Free LISP routines library
  • AutoLISP on AutoCAD LT
  • AutoLISP Lesson 10: Input and Output

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