Help with lisp, see code inside

Status
Not open for further replies.

Donald Varino

Usenet Archive
Joined
Jan 21, 2001
Messages
26
Reaction score
0
How can I get this routine to allow multiple blocks deletions? I want to be able to type in more than 1 block at the prompt. Better yet I would like for this routine to gather up all of the blocks inserted in the drawing, make a list of them through a dialog and I can multiple select them from there to delete them.... Any help would be greatly appreciated.

(Setq N (Strcase (Getstring "\n\nEnter block name to delete ... "))) (Setq A 0) (Setq E (Entnext)) (While E (If (= N (cdr (Assoc 2 (Entget E))))(progn (Entdel E) (Setq A (1+ A)) ) ) (Setq E (Entnext E))) (Prompt "\n") (prompt (Itoa A)) (prompt " blocks deleted"\n)
(Princ)

Thanks,

Don
 
Make your selection set with (ssget):

(setq n (getstring "\nName of Block: ")
ss (ssget "x" (list '(0 . "INSERT")(cons 2 n)))
) ;; setq

then delete the selection set:

(command "_.erase" ss "")
or
(setq ct (1- (sslength ss)))
(while (>= ct 0)
(entdel (ssname ss ct))
(setq ct (1- ct))
) ;; while
___

"Donald Varino" wrote:

How can I get this routine to allow multiple blocks deletions? I want to
be
able to type in more than 1 block at the prompt. Better yet I would like
for
this routine to gather up all of the blocks inserted in the drawing, make
a
list of them through a dialog and I can multiple select them from there to delete them.... Any help would be greatly appreciated.

(Setq N (Strcase (Getstring "\n\nEnter block name to delete ... "))) (Setq A 0) (Setq E (Entnext)) (While E (If (= N (cdr (Assoc 2 (Entget E))))(progn (Entdel E) (Setq A (1+ A)) ) )
...
 
To expand a little on Paul's response;

(setq n (getstring "\nName of Block: ")
ss (ssget "x" (list '(0 . "INSERT")(cons 2 n)))
) ;; setq

then delete the selection set:

(command "_.erase" ss "")

Using this approach, you can erase multiple INSERT's simply by responding with something similar to;

BL*,XYZ,123??

Which would erase all INSERT's using "BL" as the first two characters, followed by any number of other characters.

Insert's named "XYZ" and any INSERT's named "123" followed by 2 additional characters

HTH

Jim
 
Status
Not open for further replies.

Latest threads

Back
Top