AutoLISP: Erase Continuously (new & improved)

So Lee answered once again and combined the two previous routines into one awesome routine. You remain in the erase command and are able to select objects by 1) picking them 2) Window 3) Crossing window and as soon as you are done selecting them, they are erased.

; Erase Continuous by Lee Mac

(defun c:ec ( / fl p1 p3 ls hi ss )

(princ "\nSelect Objects to Erase: ")

(while (and (not fl) (= 3 (car (setq p1 (grread nil 12 2)))))

(if (setq ss (ssget (setq p1 (cadr p1))))

(command "_.erase" ss "")

(progn

(princ "\nSpecify Opposite Corner: ")

(while (= 5 (car (setq p3 (grread t 13 0))))

(redraw)

(setq p3 (cadr p3))

(setq ls

(list

p1

(list (car p3) (cadr p1) (caddr p1))

p3

(list (car p1) (cadr p3) (caddr p1))

)

)

(setq hi (if (< (car p1) (car p3)) 0 1))

(mapcar '(lambda ( a b ) (grdraw a b -1 hi)) ls (append (cdr ls) (list p1)))

)

(if (listp (setq p3 (cadr p3)))

(if (setq ss (ssget (if (< (car p1) (car p3)) "_W" "_C") p1 p3))

(command "_.erase" ss "")

)

(setq fl t)

)

(redraw) (princ "\nSelect Objects to Erase: ")

)

)

)

(redraw) (princ)

)
Advertisement

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Modifying, TIPS. Bookmark the permalink.

1 Response to AutoLISP: Erase Continuously (new & improved)

  1. CARLOS DE LA ROSA says:

    well, this works excellent!!! tnx!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s