AutoLISP: Erase Continuous With a Window

A lot of the drawings that I get I end up erasing a lot of stuff. And after using SkethUP’s erase command, I wish that AutoCAD’s erase command worked in the same way. I asked Lee-Mac for help with this and he delivered a great little routine that I am sure you guys will enjoy.

What it does is let you select objects with either a window or crossing window. And after making the selection set it automatically erases the selection and continues the erase command.

Here’s How:

  • EC <enter> to start Erase Continuous
  • Make selection sets with a Window or Crossing Window
  • The command will stay in a loop, so to end the routine, hit the escape <ESC> button

; Erase Continuous by Lee-Mac

(defun c:ec ( / p1 p2 ss )



(setq p1 (getpoint "\nSpecify First Corner: "))

(setq p2 (getcorner "\nSpecify Opposite Corner: " p1))


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

(command "_.erase" ss "")





Here is a version that uses the grread function

;Erase Continuous by Lee-Mac. Uses grread

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


(and (setq p1 (getpoint "\nSpecify First Corner: "))


(princ "\nSpecify Opposite Corner: ")

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


(setq p3 (cadr p3))

(setq ls



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


(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)))


(listp (setq p3 (cadr p3)))




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

(command "_.erase" ss "")



(redraw) (princ)


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.

2 Responses to AutoLISP: Erase Continuous With a Window

  1. CARLOS DE LA ROSA says:

    hi!! I was looking for something for the midbutton menu, something like this!!:

    something simple but i can’t remember how it’s wrote!!!

  2. Laranjeira says:

    In pop menu use this macro *^C^C_erase si auto

Leave a Reply

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

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

Twitter picture

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

Facebook photo

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

Connecting to %s