When cleaning up complex AutoCAD drawings, removing an unwanted or outdated block symbol scattered across dozens of locations is a frequent hassle. Using QSELECT, setting up selection filters, or hunting down individual block references across separate layers and paper space layouts eats up precious drafting time and often leaves hidden instances behind.
The BDA.lsp (Block Delete All) routine turns this cleanup task into a single click. Simply pick one instance of the target block on your screen, and the script instantly searches the entire drawing database to erase every matching block reference in a fraction of a second.
Why BDA.lsp Streamlines Drawing Cleanup
Database-Wide Sweeping: Uses a global database search (
ssget "X") to ensure no hidden or isolated block references remain anywhere in your drawing.Eliminates Filter Setup: Bypasses manual Quick Select (
QSELECT) menus, layer isolation, or complex object filters completely.Zero Human Error: Guarantees a 100% complete purge of the selected block symbol, preventing missed elements during final drawing submission.
Step-by-Step Instructions
Load
BDA.lspinto your AutoCAD session using theAPPLOADcommand.Type
BDAin the command prompt and hit Enter.Select any single instance of the block you want to completely remove.
The script immediately erases all identical block references drawing-wide and reports the total count of deleted items in the command window.
AutoLISP Code (BDA.lsp)
Copy the code below and save it as BDA.lsp inside your AutoCAD support folder:
(defun c:BDA ( / *error* oldecho oldosmode ent blkName ss i acadObj activeDoc)
(vl-load-com)
(setq acadObj (vlax-get-acad-object)
activeDoc (vla-get-ActiveDocument acadObj)
oldecho (getvar "CMDECHO")
oldosmode (getvar "OSMODE"))
(defun *error* (msg)
(if oldecho (setvar "CMDECHO" oldecho))
(if oldosmode (setvar "OSMODE" oldosmode))
(vla-EndUndoMark activeDoc)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
(setvar "CMDECHO" 0)
(vla-StartUndoMark activeDoc)
(if (and (setq ent (car (entsel "\nSelect a block to delete all instances: ")))
(= (cdr (assoc 0 (entget ent))) "INSERT"))
(progn
(setq blkName (cdr (assoc 2 (entget ent))))
(if (setq ss (ssget "X" (list '(0 . "INSERT") (cons 2 blkName))))
(progn
(setq i (sslength ss))
(while (> i 0)
(setq i (1- i))
(entdel (ssname ss i))
)
(princ (strcat "\nSuccess: All " (itoa (sslength ss)) " instances of block '" blkName "' have been deleted."))
)
)
)
)
(vla-EndUndoMark activeDoc)
(setvar "CMDECHO" oldecho)
(setvar "OSMODE" oldosmode)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
Post-Cleanup Tip
After running BDA.lsp to delete all block instances from your drawing screen, run the PURGE command (PU) to clear the unused block definition from your file's memory and reduce overall file size.

Post a Comment