Jump to content

custom erase command


jovo14

Recommended Posts

I am looking for help with a special erase command. I would like to select objects one by one and have then delete as I select them.

 

Can someone advise how to write this command?

 

Thx

Link to comment
Share on other sites

Welcome to CADTutor, and the world of LISP! :beer:

 

(defun c:Erase+ (/ eName layerName)
 (while
   (and
     (setq eName (car (entsel "\nSelect an entity to erase: ")))
     (setq layerName (cdr (assoc 8 (entget eName))))
     (/= 4 (cdr (assoc 70 (tblsearch "layer" layerName))))
   )
    (command "._erase" eName "")
 )
 (princ)
)

Link to comment
Share on other sites

Another,

 

(defun c:e1 ( / e )
   (while (setq e (car (entsel))) (entdel e))
   (princ)
)

 

Or, to allow for missed picks:

 

(defun c:e1 ( / e )
   (while
       (progn (setvar 'errno 0) (setq e (car (entsel)))
           (cond
               (   (= 7 (getvar 'errno))
                   (princ "\nMissed, try again.")
               )
               (   (= 'ename (type e))
                   (entdel e)
                   t
               )
           )
       )
   )
   (princ)
)

Link to comment
Share on other sites

You do not need a lisp routine to accomplish the task. I've had this ability for many years simply by using this:

 

*^C^CErase;\;

 

Nice and simple...Thanks

 

:beer:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...