AutoLISP: Erase Single

Here is another erase routine that lets you select only one object at a time but like the previous post, it erases the selected object and then continues the erase command.

My ultimate goal would be to combine these 2 routines into one.

;; erase single

;; found at


(defun c:es (/ ent ecnt eprompt)

(setvar "ERRNO" 0)

(setq eprompt "\nSelect object: "

ecnt 0


(while (or (setq ent (entsel eprompt))

(eq 7 (getvar "errno"))



((= ent "Undo")

(command "u")

(setq ecnt (1- ecnt))


((= (type ent) 'list)

(command "erase" ent "")

(setq ecnt (1+ ecnt))


(t nil)


(setvar "ERRNO" 0)

(if (not (zerop ecnt))


(setq eprompt "\nUndo/<Select object>: ")

(initget "Undo")


(setq eprompt "\nSelect object: ")





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.

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 )

Facebook photo

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

Connecting to %s