Lisp to delete all blocks of various name

Lisp to delete all blocks of various name

Anonymous
Not applicable
5,687 Views
22 Replies
Message 1 of 23

Lisp to delete all blocks of various name

Anonymous
Not applicable

My experience with lisp is finding code that sort of does what I want, editing and hoping for the best. Thru trial and error, research and a little luck I usually stumble on a workable solution. Today I'm stuck.

For construction drawings I need a number of entities in floor plan cad that client wants stripped from cad before passing it to them. I'm trying to delete all instances of a list of different blocks.

Code below works for single line selecting "pq-*" or "RefQ*" but with both lines nothing is deleted and error at bottom is returned. Hope this is a simple one, what am I missing?

 

(defun c:del4q ()
(sssetfirst nil (ssget "_x" '((2 . "pq-*"))))(command "_.erase")
(sssetfirst nil (ssget "_x" '((2 . "RefQ*"))))(command "_.erase")
(princ)
)

 

Command: DEL4Q
_.erase
Select objects: _.erase
*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/Previous/Undo/AUto/SIngle/SUbobject/Object

 

Thanks in advance.

0 Likes
Accepted solutions (2)
5,688 Views
22 Replies
Replies (22)
Message 21 of 23

Lee.MalaspinaJMHCX
Participant
Participant

I did an extensive search snd found a solution to this probem. Since nobody was interested in addressing the actual problem, I won't waste any time with the solution. Thanks a lot.

0 Likes
Message 22 of 23

Lee.MalaspinaJMHCX
Participant
Participant
Yes, i tried various things that worked in other scripts. No luck with that.
0 Likes
Message 23 of 23

Lee.MalaspinaJMHCX
Participant
Participant

I did some research and found a solution to my problem, which was running it on numerous files.Thanks to the few that actually tried to assist me with the actual problem and comprehended it. 

0 Likes