khoshravan Posted August 14, 2011 Posted August 14, 2011 I want to draw many circles with "3P" options. Every time I have to hit the space bar for repetition and select the option. A couple of weeks a go I read a post here in CT which taught how to automate this part of commands. I don't know how to find it. Will be happy if somebody guide me how to find it Quote
Lee Mac Posted August 14, 2011 Posted August 14, 2011 As a macro: ^C^C_.circle;_3p As a LISP: (defun c:c3po nil (command "_.circle" "_3p" pause pause pause) (princ)) Quote
nestly Posted August 14, 2011 Posted August 14, 2011 The lisp works great when using or to repeat the last command, but when I tried to repeat the macro, it only repeated the circle command (without the 3P option). This may or may not be the same thing the OP is asking, but I'd like AutoCAD to remember the circle option that was last used when using or to repeat a command. Quote
Lee Mac Posted August 14, 2011 Posted August 14, 2011 The lisp works great when using or to repeat the last command, but when I tried to repeat the macro, it only repeated the circle command (without the 3P option). This may or may not be the same thing the OP is asking, but I'd like AutoCAD to remember the circle option that was last used when using or to repeat a command. That's correct, the space will repeat the last used command, hence repeating the LISP command; however, since the macro doesn't define a command in itself, it isn't repeated, so you would have to press the toolbar button again. Quote
irneb Posted August 15, 2011 Posted August 15, 2011 Of course not the "best" way of doing it: (defun c:C3PR ( / ) (while t (command "._CIRCLE" "_3P" pause pause pause)) (princ)) No need for space even, but you have to use ESC to stop! Quote
khoshravan Posted August 16, 2011 Author Posted August 16, 2011 As a macro: ^C^C_.circle;_3p I thought it can be typed in command line. But it says: Unknown command "CIRCLE;_3P". Press F1 for help. Am I doing something wrong? Quote
khoshravan Posted August 16, 2011 Author Posted August 16, 2011 As a LISP: (defun c:c3po nil (command "_.circle" "_3p" pause pause pause) (princ)) It works good. Isn't it possible to add a "space bar" or "enter" to this code to make life easier? Quote
khoshravan Posted August 16, 2011 Author Posted August 16, 2011 Also I should add that my question is in general. I raised drawing circle with 3p as an example. I want to know it for other commands as well. Quote
Lee Mac Posted August 16, 2011 Posted August 16, 2011 I thought it can be typed in command line. The macro is for use with toolbar buttons for example. Quote
Lee Mac Posted August 16, 2011 Posted August 16, 2011 It works good. Isn't it possible to add a "space bar" or "enter" to this code to make life easier? I don't follow Quote
irneb Posted August 16, 2011 Posted August 16, 2011 It works good. Isn't it possible to add a "space bar" or "enter" to this code to make life easier? I don't follow Uhmmm ... Yes ... see my reply #5 of yesterday. The only problem there is it requires you to press the Escape key to stop the command ... and then you'll see an error message at the command prompt. Quote
irneb Posted August 16, 2011 Posted August 16, 2011 (defun c:[b][color=red]c3po[/color][/b] nil (command "_.circle" "_3p" pause pause pause) (princ)) What happened to R2D2? Quote
khoshravan Posted August 16, 2011 Author Posted August 16, 2011 The macro is for use with toolbar buttons for example. Do you mean ?I should make a button and assign the macro to it? Or I lunch the command through its icon and then run the Macro?!? Quote
khoshravan Posted August 16, 2011 Author Posted August 16, 2011 Of course not the "best" way of doing it:(defun c:C3PR ( / ) (while t (command "._CIRCLE" "_3P" pause pause pause)) (princ)) No need for space even, but you have to use ESC to stop! Dear Irneb I checked your lisp today. Thanks it works as you say. I think clicking the esc at the end is better than clicking space every time. I think the "while t" makes it to repeat. Am I correct? But why did you write : Of course not the "best" way of doing it? I don't know LISP but out of curiosity why do you put three pause? Isn't one enough to pause or it is a security measure? Quote
Lee Mac Posted August 16, 2011 Posted August 16, 2011 Do you mean ?I should make a button and assign the macro to it?Or I lunch the command through its icon and then run the Macro?!? Create a new toolbar button and copy the macro code to the 'macro' part of the toolbar button properties. Quote
irneb Posted August 16, 2011 Posted August 16, 2011 Do you mean ?I should make a button and assign the macro to it?Or I lunch the command through its icon and then run the Macro?!? Lee means that is the code for the macro of the "Command" inside the CUI. This command you can then assign to a button on a toolbar / ribbon, as an item in the menu, as a keyboard shortcut, as an item in a pop-up menu, etc. etc. etc. Dear Irneb I checked your lisp today. Thanks it works as you say. I think clicking the esc at the end is better than clicking space every time. I think the "while t" makes it to repeat. Am I correct? But why did you write : Of course not the "best" way of doing it? I don't know LISP but out of curiosity why do you put three pause? Isn't one enough to pause or it is a security measure? Thanks I'm glad it works for you. You're correct the (while T ... is a loop which checks if the 1st item inside it is not nil, then runs everything inside it and checks again. The T (or "true") will simply never be nil, so actually it's what's called an "infinite loop". The reason I say it's "not the best way" is because of this infinite loop. It relies on the user pressing the Escape, which for a Lisp function means: "Cancel everything, there's an ERROR!" Quote
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.