Jump to content

Recommended Posts

Posted

I am trying to place a custom erase command in my custom lisp file.

I have to enter two separate commands to get to a multiple erase single objects.

I want to combine the two commands below and remain in the command until enter esc.

 

(defun C:MU () (command "multiple"))

(defun C:ER () (command "erase" "si"))

 

Right now I:

1. enter MU

2. ER

3. pick an object (it gets erased)

4. enter to repeat

5. when finished press the esc key to end.

 

I want to eliminate step 4.

 

 

Can anyone help?

  • Replies 29
  • Created
  • Last Reply

Top Posters In This Topic

  • CADNICK

    13

  • BlackBox

    11

  • alanjt

    4

  • Tharwat

    2

Popular Days

Top Posters In This Topic

Posted (edited)

Try this:

 

<Code Removed... this is dumb>

 

Note - Instead of hitting ESC when done, simply right+click... ESC is not considered to be a "best practice" for properly exiting any command.

 

HTH

Edited by BlackBox
Posted

Thanks.

How can I get it to erase as I select the object instead of only erasing after I press enter after selecting each object?

 

Try this:

 

(defun c:MUE  (/ *error* oldNomutt oldCmdecho ss)
 (princ "\rMULTIPLE ERASE ")
 (vl-load-com)

 (defun *error*  (msg)
   (and oldNomutt (setvar 'nomutt oldNomutt))
   (and oldCmdecho (setvar 'cmdecho oldCmdecho))
   (cond ((not msg))                                                   ; Normal exit
         ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
         ((princ (strcat "\n** Error: " msg " ** "))))                 ; Fatal error, display it
   (princ))

 (and (setq oldNomutt (getvar 'nomutt)) (setvar 'nomutt 1))
 (and (setq oldCmdecho (getvar 'cmdecho)) (setvar 'cmdecho 0))
 (while (/= nil (setq ss (ssget)))
   (vl-cmdf "._erase" ss ""))
 (and (setvar 'nomutt oldNomutt) (setvar 'cmdecho oldCmdecho))
 (princ))

 

Note - Instead of hitting ESC when done, simply right+click... ESC is not considered to be a "best practice" for properly exiting any command.

 

HTH

Posted
Thanks.

How can I get it to erase as I select the object instead of only erasing after I press enter after selecting each object?

 

The code I posted allows you to repeatedly select multiple objects at once. You are no longer limited to selecting one-object-at-a-time.

 

I've added an additional prompt to better clarify this functionality.

 

Edit: Otherwise, you just want to use the erase command normally (i.e., without the "single" parameter you chose to add above).

Posted

What would the lisp look like if I wanted to select one object at a time?

Posted

I am trying to erase one object at a time without pressing enter until I cancel the command.

Posted (edited)
I am trying to erase one object at a time without pressing enter until I cancel the command.

 

 

Code revised (again):

 

<Code Removed... this is dumb>

Edited by BlackBox
Code revised at OP request for third time.
Posted

It works great.

 

If I miss an object by picking an empty area or try to use a window/crossing window it ends the command. Can it be modified to accept a windowing option?

Posted

Basicly I want to combine my "mu" and "er" into one command.

 

(defun C:MU () (command "multiple"))

(defun C:ER () (command "erase" "si"))

Posted
It works great.

 

If I miss an object by picking an empty area or try to use a window/crossing window it ends the command. Can it be modified to accept a windowing option?

 

Here's all I have time for... (code revised above).

 

Good luck!

Posted

Thanks Renderman. I appreciate the help but I think I'm stuck with entering my "mu" "er" combination for now.

Posted
Thanks Renderman. I appreciate the help but I think I'm stuck with entering my "mu" "er" combination for now.

 

No worries, I'm always happy to not help.

Posted
No worries, I'm always happy to not help.

 

Yeah, with lisp that sometimes happens.

Posted
Yeah, with lisp that sometimes happens.

 

Only with you, dude... Good luck with "mu" & "er".

Posted

I guess I'll have to consult the Albus Dumbledore or Gandalf the Grey of lisp.

Posted
I guess I'll have to consult the Albus Dumbledore or Gandalf the Grey of lisp.

 

Admittedly, I do not have all the answers.

 

I know members whom possess a mastery of LISP, who are also Brits. However, if there exists a "Dumbledore of LISP," you might first consider other options which include, but are not limited to:

  • Using the erase command without the "single" parameter relegation
  • Reading the Developer Documentation, demonstrating a good-faith effort to write your own routine (asking for help when needed of course, everybody starts somewhere)

... Before seeking an audience. Really... what ever works best for you, my friend.

 

FWIW - Right click following a selection (single, window, crossing, etc.) is not uncommon in custom and core AutoCAD commands alike. Just saying.

 

Cheers! :ButterBeer:

Posted
Admittedly, I do not have all the answers.

 

 

I know members whom possess a mastery of LISP, who are also Brits. However, if there exists a "Dumbledore of LISP," you might first consider other options which include, but are not limited to:

  • Using the erase command without the "single" parameter relegation
  • Reading the Developer Documentation, demonstrating a good-faith effort to write your own routine (asking for help when needed of course, everybody starts somewhere)

... Before seeking an audience. Really... what ever works best for you, my friend.

 

FWIW - Right click following a selection (single, window, crossing, etc.) is not uncommon in custom and core AutoCAD commands alike. Just saying.

 

Cheers! :ButterBeer:

 

What I like about the "single" part of the command is that is deletes the object as soon as it's selected. What I like about the "multiple" is that it keep the command going.

 

As to the suggestion about writing my own routine...I gave it a try but only got as far as what I posted above. I'm a newbie at lisp so I figured I would consult the more advanced in the world of lisp. Having a hard time sorting out the Developer Documentation.

 

Thanks again for the help Renderman.

Posted
What I like about the "single" part of the command is that is deletes the object as soon as it's selected. What I like about the "multiple" is that it keep the command going.

 

As to the suggestion about writing my own routine...I gave it a try but only got as far as what I posted above. I'm a newbie at lisp so I figured I would consult the more advanced in the world of lisp. Having a hard time sorting out the Developer Documentation.

 

Thanks again for the help Renderman.

 

No worries, we all start somewhere. I'm certainly not here to pick a fight with anyone... not that long ago I was in your shoes.

 

Perhaps I did a poor job of communicating why it is that I felt that your suggested method was less effective than that which I proposed. It's just hard for me (not being in your shoes) to understand why you would want to make things more complicated than they need to be... not that it cannot be done necessarily. But still.

 

Why do you not simply use the erase command, and select each entity you want deleted, and right click once? This also provides the option for deselecting entities that were selected in error, rather than having then to undo the deletion, and start over.

Posted
(defun c:Test (/ entity)
 (while (setq entity (car (entsel "\nSelect object to erase: ")))
   (entdel entity)
 )
 (princ)
)

Posted (edited)
No worries, we all start somewhere. I'm certainly not here to pick a fight with anyone... not that long ago I was in your shoes.

 

Perhaps I did a poor job of communicating why it is that I felt that your suggested method was less effective than that which I proposed. It's just hard for me (not being in your shoes) to understand why you would want to make things more complicated than they need to be... not that it cannot be done necessarily. But still.

 

Why do you not simply use the erase command, and select each entity you want deleted, and right click once? This also provides the option for deselecting entities that were selected in error, rather than having then to undo the deletion, and start over.

 

Yeah, sometimes I do that but other times I like the option of click-and-gone especially in cluttered drawings with lots of construction lines. Sometimes it's nice to have the ability to erase by picking, windowing, & crossing and staying in the command without hitting enter with each click of the mouse. Just a nice-to-have option. Depends on the situation. My "mu" and "er" (post #1 above) get me there for now.

Edited by CADNICK

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...