MikeP Posted January 22, 2011 Share Posted January 22, 2011 i want to take a command that ends and make it repeat it self untll it hit esc Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 22, 2011 Share Posted January 22, 2011 Here it goes . Command:[color=red][b] multiple[/b][/color] Enter command name to repeat: circle Good luck. Tharwat Quote Link to comment Share on other sites More sharing options...
MikeP Posted January 22, 2011 Author Share Posted January 22, 2011 well that didnt work. Im using a 3rd party software in cad and the command i want just goes into an endless loop that does not work when I do that Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 22, 2011 Share Posted January 22, 2011 Does that 3rd Software behave as well as Autocad ? Or could you invoke an autolisp routine in that software ? Regards Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted January 22, 2011 Share Posted January 22, 2011 Are you writing a lisp program? If so, Just look into while. See this link:http://www.afralisp.net/archive/lispa/lisp10.htm Quote Link to comment Share on other sites More sharing options...
MikeP Posted January 22, 2011 Author Share Posted January 22, 2011 I can. It works inside of cad. all the commands from this software are basically lisp Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 22, 2011 Share Posted January 22, 2011 The same as the Buzzard mentioned with the function While , you can start with things like this (while (if (and (setq pt (getpoint "\n Specify center of circle :")) (setq dia (getdist pt "\n Specify diameter of Circle :")) ) (entmakex (list (cons 0 "CIRCLE") (cons 10 pt) (cons 40 dia) ) ) (princ) ) ) Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 22, 2011 Share Posted January 22, 2011 ...you can start with things like this FYI, no need for the IF (setq n (trans '(0. 0. 1.) 1 0 t)) (while (and (setq p (getpoint "\nSpecify Center of Circle: ")) (setq d (getdist p "\nSpecify Diameter of Circle: ")) ) (entmakex (list (cons 0 "CIRCLE") (cons 10 (trans p 1 n)) (cons 40 d) (cons 210 n) ) ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 22, 2011 Share Posted January 22, 2011 That's right IF the OP did not want to hit ESC to stop looping according to his first post. Thanks. Tharwat Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted January 22, 2011 Share Posted January 22, 2011 I can. It works inside of cad. all the commands from this software are basically lisp Mike, If this is a third party app you are trying to change, I do not suggest you mess with it unless you are very experienced at lisp and also you should check if the licence agreement allows you to edit this program as well. If you want to write you own application, You should learn the basics of lisp first. You can learn it at the same site I linked you to. You can also always come here for the additional help also. What you will need to do is be more specific as to what you are trying to accomplish and we can better advise you of the direction you need to take. Let us know and good luck, The Buzzard Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted January 22, 2011 Share Posted January 22, 2011 One more thing to know. You really do not want to hit Esc to end a program as this intentionally causes an error. If your program is written correctly and is error trapped as well as have away to end cleanly, All you really need to do is right click your mouse or press a specific key to end the program if the while loop is written properly. Just some food for thought. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 22, 2011 Share Posted January 22, 2011 If you don't have access to the third party source, it is difficult to control the loop as you have no control over the input parameters, and similarly perhaps don't know the returns of the program. For example, if the program returns a non-nil value if successful (else nil if unsuccessful), a simple loop could be: (while (c:MyProgram)) If this is not the case then there are few alternatives: (while (not ExitFlag) (c:MyProgram) (initget "Yes No") (setq ExitFlag (eq "Yes" (getkword "\nExit? [Yes/No] <No> : "))) ) In this case, you must ensure the variable 'ExitFlag' is localised. (while t (c:MyProgram)) I would be reluctant to use the last example since it forces the user to hit Esc to exit the program which is bad practice in my eyes. Lee Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted January 22, 2011 Share Posted January 22, 2011 If you don't have access to the third party source, it is difficult to control the loop as you have no control over the input parameters, and similarly perhaps don't know the returns of the program. For example, if the program returns a non-nil value if successful (else nil if unsuccessful), a simple loop could be: (while (c:MyProgram)) If this is not the case then there are few alternatives: (while (not ExitFlag) (c:MyProgram) (initget "Yes No") (setq ExitFlag (eq "Yes" (getkword "\nExit? [Yes/No] <No> : "))) ) In this case, you must ensure the variable 'ExitFlag' is localised. (while t (c:MyProgram)) I would be reluctant to use the last example since it forces the user to hit Esc to exit the program which is bad practice in my eyes. Lee Well said Lee. It is important to get that point across. Just not sure of the OP's experience. I would hate to encourage someone editing a third party app if they are unsure of themselves. They are left with a program they paid for that will no longer function. It is best to show them how to build their own app. Not much lost and everything to gain. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted January 22, 2011 Share Posted January 22, 2011 i want to take a command that ends and make it repeat it self untll it hit esc A button macro starting with the * character will make that command to repeat until the user hits Esc. Does it work with external commands? Quote Link to comment Share on other sites More sharing options...
StevJ Posted January 23, 2011 Share Posted January 23, 2011 A button macro starting with the * character will make that command to repeat until the user hits Esc. Does it work with external commands? I have tried, but have never been successful getting this to work for external commands. Steve Quote Link to comment Share on other sites More sharing options...
irneb Posted January 24, 2011 Share Posted January 24, 2011 You could use the vlax-add-cmd function to convert the c:CommandName defun into a "true" autocad command. Then the Multiple thingy should work. E.g. say the command is Test, then: (setq test c:Test c:Test nil) (vlax-add-cmd "TEST" 'test) No need to modify the original code, just make sure the above is loaded after loading the 3rd party app. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 24, 2011 Share Posted January 24, 2011 You could use the vlax-add-cmd function to convert the c:CommandName defun into a "true" autocad command. Then the Multiple thingy should work. E.g. say the command is Test, then:(setq test c:Test c:Test nil) (vlax-add-cmd "TEST" 'test) No need to modify the original code, just make sure the above is loaded after loading the 3rd party app. Nice idea - also handy if you want to run a LISP command transparently 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.