• 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

BLOCKPURGE LISP: Delete a Block and All Its References

August 3, 2026

The standard PURGE command only removes definitions that are already unused. When a block is still inserted somewhere it simply refuses, and you are left hunting for the last stray reference — which may well be nested three blocks deep on a layout you had forgotten about. BLOCKPURGE does the whole job.

What BlockPurge does

It erases every reference at every level of nesting, across every layout, and then removes the definition. One command instead of a search.

Two ways to choose a block. Pick one in the drawing, or type N for a filtered list of every block defined in the drawing, from which several can be selected at once. The list has a filter box — type part of a name and it narrows.

The routine reports which blocks it removed and which it could not. A block may survive because it is referenced by a dimension style, a multileader style or a table style rather than by any geometry, and being told that is a great deal more useful than being told it failed.

How to use it

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Type BLOCKPURGE.
  3. Pick a block in the drawing, or type N for the list.
  4. In the list, type part of a name to filter, and select as many blocks as you want.
  5. Read the report — it names anything that could not be removed and why.

How it works

Locked layers are handled rather than skipped. References on locked layers would refuse to be deleted, so locked layers are temporarily unlocked, the deletions performed, and the locks restored exactly as they were. Any layer that was not locked is left untouched — the routine restores the state it found, not a state it assumed.

Nesting is followed all the way down. A reference inside a block inside a block is still a reference, and it is the one that keeps PURGE refusing.

There is a documented entry point for batch use. BlockPurge:Delete takes a document object and a list of block names, and can be called from your own scripts. It works with ObjectDBX documents too, so it can process drawings without opening them — which is how you strip a superseded symbol out of a whole project folder.

Notes and limits

  • This deletes drawing content. Every reference of the chosen block goes, everywhere. Be sure of the name before confirming.
  • Some blocks legitimately cannot be purged. If a dimension, multileader or table style references the block, the definition stays and the report says so.
  • Locked layers are unlocked and relocked, so the layer state you had is the layer state you get back.
  • One undo group covers the whole operation within a single drawing.

Download and details

NameBlockPurge — delete every reference of a block, then purge the definition
DownloadBlockPurge.lsp — 15.3 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandBLOCKPURGE
Requiresthe ActiveX layer (loaded automatically by the routine with vl-load-com); nothing extra — the dialog is written to a temporary file at run time and deleted again, so there is no .dcl to install.
Source size15.3 KB, 380 lines
Error handlingYes — a *error* handler restores every system variable it changed, on cancel as well as on error.
UndoThe whole operation is wrapped in a single undo group, so one U reverses all of it.
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 — count what is actually in the drawing before purging it
  • Delete Layer LISP — the same job for layers
  • 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