AutoCAD/Keystroke command
Expert: Bill DeShawn - 4/16/2004
QuestionI had in my acad.lsp file several keystroke commands similiar to acad.pgp. I forgot to make a backup file and overwrote the lsp file when I installed ver 2004. I can't remember how the lisp defun was typed in my acad.lsp file.
Here is what I used to have....
command:LEE
would be line (endpoint)(endpoint)
or
command:LCP
would be line (center)(perpendicular)
I had made several of these for a one time use of my line command. I don't like to have osnap on all of the time and these worked great for me.
I've tried to add them to my acad.lsp file but I can't get them to work. I get the first point but not the second. I get a bad function error
Here is how I am putting it into my lsp file...
(defun c:lcc()(command"line""cen")("cen"))
for a line center to center
I remember it was similiar to this.
Can you help me?
Thanks
Steve
AnswerSteve: What you are doing is exactly how I got started in LISP for AutoCAD.
(defun c:lcc () (command "_.line" "cen" pause "cen" pause "")(princ))
As you already know, c:lcc is the name of the function which you can use as a command. The () parentheses can contain words called local variables and arguments. More LISP study will help you with that. The underscore before the line command is so that the routine or macro can be used even in international versions of AutoCAD in other languages. The dot means that if the line command has been redefined, it will refer to only AutoCAD's version of the line command. In this case, everything in quotes is what a user would type at the command line to accomplish what he needs done. The pauses refer to user input. It could be typed in or picked with the mouse. In the case of this macro, the user input will be made with the mouse. The (princ) function cleans up AutoLISP messaging so that it doesn't return "nil" at the command line when you are done with the function.
See if that is enough to get you by for now, using the same principles in the rest of your macros in ACAD.LSP.
Keep in touch
Bill DeShawn
http://my.sterling.net/~bdeshawn