Here it is with the (getstring) for block name user input, I find it dangerouse because it is a total wildcard, it will filter by one letter and get all blocks that contain that one letter or you can spell out a portion of the desired block name to narrow down your selection.
WARNING: This routine can delete blocks not intended to be deleted if too few letters are used for the selection set filter.
example: if you enter "s" it will delete every block with an "s" in the name.
if you enter "seal" it will delete all the blocks with "seal" in the name.
if you enter "se" it will delete all the blocks with "se" in the name, including "seal" because "se" is part of "seal"
If this routine acts any different to what I explained above, please let me know, for I am a beginner and this makes me dangerouse.
Thanks
(defun c:TEST ( / blkName sset cnt ent entData entName entTblName )
(vl-load-com)
;--------------------------------------------------------------------------------------------------------------------------
(vla-StartUndoMark acadActiveDocument)
;==========================================================================================================================
;
;==========================================================================================================================
(setq blkName (getstring "\nEnter Block Name: "))
(if
(setq sset (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "*" blkName "*")))))
(progn
(setq cnt 0)
(repeat (sslength sset)
(setq
ent (ssname sset cnt)
entData (entget ent)
entName (cdr (assoc 2 entData))
entTblName (tblobjname "block" entName)
)
(entdel ent)
(vl-catch-all-apply 'vla-delete (list (vlax-ename->vla-object (cdr (assoc 330 (entget entTblName))))))
(setq cnt (1+ cnt))
)
)
(alert "No Block Definition in Drawing")
)
;==========================================================================================================================
;
;==========================================================================================================================
(vla-EndUndoMark acadActiveDocument)
;--------------------------------------------------------------------------------------------------------------------------
(princ)
)