OK.
I could do the first bit, but you did that for me here, but the rest is a mystery.
can you give me a few pointers.
You wouldn't really do it the way Alan says. You want to search the block definitions, and then delete the object for there. I think it is easier to go the ActiveX route with this. To step through the block collection for the current drawing you would do
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vlax-for Blk (vla-get-Blocks ActDoc)
....
)
This is saying that you want to search all blocks in the block collection.
While you are searching the blocks collection, you want to search each blocks definition, so you would do that like
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vlax-for Blk (vla-get-Blocks ActDoc)
(if (wcmatch (strcase (vla-get-Name Blk)) "WALL*")
(vlax-for Obj Blk
....
)
)
)
This is saying that you want to search all objects that make up the blocks definition if the name of the blocks starts with the characters "WALL".
Now you want to test the object to see if it is a wipeout or a hatch pattern, and if so delete them
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vlax-for Blk (vla-get-Blocks ActDoc)
(if (wcmatch (strcase (vla-get-Name Blk)) "WALL*")
(vlax-for Obj Blk
(if
(or
(= (vla-get-ObjectName Obj) "AcDbHatch")
(= (vla-get-ObjectName Obj) "AcDbWipeout")
)
(vla-Delete Obj)
)
)
)
)
Now you want to put that into a function you can call from the command line, so add a defun to it (whatever you like, you can change the name)
(defun c:CleanUpBlocks (/ ActDoc)
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vlax-for Blk (vla-get-Blocks ActDoc)
(if (wcmatch (strcase (vla-get-Name Blk)) "WALL*")
(vlax-for Obj Blk
(if
(or
(= (vla-get-ObjectName Obj) "AcDbHatch")
(= (vla-get-ObjectName Obj) "AcDbWipeout")
)
(vla-Delete Obj)
)
)
)
)
(princ)
)
To use ActiveX controls you have to have
(vl-load-com)
Somewhere that will get loaded into Acad at least once per session (if loaded more that once no big deal).
Hope that makes sense.
Edit: I guess you would want to make sure that the blocks you are trying to search are not a layout or an xref, to do so the code would change to look like
(defun c:CleanUpBlocks (/ ActDoc)
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vlax-for Blk (vla-get-Blocks ActDoc)
(if
(and
(equal (vla-get-IsXref Obj) :vlax-false)
(equal (vla-get-IsLayout Obj) :vlax-false)
(wcmatch (strcase (vla-get-Name Blk)) "WALL*")
)
(vlax-for Obj Blk
(if
(or
(= (vla-get-ObjectName Obj) "AcDbHatch")
(= (vla-get-ObjectName Obj) "AcDbWipeout")
)
(vla-Delete Obj)
)
)
)
)
(princ)
)