CADNICK Posted July 18, 2011 Share Posted July 18, 2011 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? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 18, 2011 Share Posted July 18, 2011 (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 July 18, 2011 by BlackBox Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 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 Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 18, 2011 Share Posted July 18, 2011 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). Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 What would the lisp look like if I wanted to select one object at a time? Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 I am trying to erase one object at a time without pressing enter until I cancel the command. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 18, 2011 Share Posted July 18, 2011 (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 July 18, 2011 by BlackBox Code revised at OP request for third time. Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 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? Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 Basicly I want to combine my "mu" and "er" into one command. (defun C:MU () (command "multiple")) (defun C:ER () (command "erase" "si")) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 18, 2011 Share Posted July 18, 2011 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! Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 Thanks Renderman. I appreciate the help but I think I'm stuck with entering my "mu" "er" combination for now. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 18, 2011 Share Posted July 18, 2011 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. Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 No worries, I'm always happy to not help. Yeah, with lisp that sometimes happens. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 18, 2011 Share Posted July 18, 2011 Yeah, with lisp that sometimes happens. Only with you, dude... Good luck with "mu" & "er". Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 I guess I'll have to consult the Albus Dumbledore or Gandalf the Grey of lisp. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 18, 2011 Share Posted July 18, 2011 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: Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 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. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 18, 2011 Share Posted July 18, 2011 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. Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 18, 2011 Share Posted July 18, 2011 (defun c:Test (/ entity) (while (setq entity (car (entsel "\nSelect object to erase: "))) (entdel entity) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
CADNICK Posted July 18, 2011 Author Share Posted July 18, 2011 (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 July 18, 2011 by CADNICK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.