NoelStalker Posted November 3, 2008 Share Posted November 3, 2008 Greetings! I came up with this lisp file to create commands to set the current layer. They are not working though and I am wondering why. Is there any problem with my code? (defun c:s0 () (command "-layer" "s" "0" "" "") ) (defun c:sd () (command "-layer" "s" "dim" "" "") ) Thanks for your assistance. Quote Link to comment Share on other sites More sharing options...
GhostRider Posted November 3, 2008 Share Posted November 3, 2008 I think you could do it this way: (defun c:s0 () (command "-layer" "s" "0" "" "")(PRINC)) (defun c:sd () (command "-layer" "s" "dim" "" "")(PRINC)) Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 3, 2008 Author Share Posted November 3, 2008 Ghost Rider, What is the (princ) function? I have seen it before but I don't know what it does. I changed my lisp file and restarted AutoCAD but the command still does not work. Here is the error it returns: "Unknown command "S0". Press F1 for help." Quote Link to comment Share on other sites More sharing options...
lpseifert Posted November 3, 2008 Share Posted November 3, 2008 How did you load your lisp file? There is nothing wrong with the code in your original post. Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 3, 2008 Author Share Posted November 3, 2008 I typed "appload" and then clicked on "contents" in the startup suite and added the lisp file to my startup suite. Then I restarted AutoCAD. What's funny is that the other commands that I define in that lisp file work fine. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 3, 2008 Share Posted November 3, 2008 I agree lpseifert, it sounds like the lisp hasn't been loaded before the syntax was called. Either load the LISP during an AutoCAD session: "_appload" Or either use the "Start-up Suite", (can be temperamental sometimes) or include a call to your LISP in the acaddoc.lsp script. Hope this helps! Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 3, 2008 Author Share Posted November 3, 2008 You guys are right. The code is good. And the command works - it sets the layer correctly. For some reason though, on the "s0" command, it still says "unknown command" even though it works. Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 3, 2008 Author Share Posted November 3, 2008 Forgot to say thanks. Thank you for all of your input. And don't forget to vote tomorrow, lpseifert Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 3, 2008 Share Posted November 3, 2008 Try this Noel - it may be why you are receiving 'unknown command': (defun c:s0 () (command "-layer" "s" "0" "")(PRINC)) (defun c:sd () (command "-layer" "s" "dim" "")(PRINC)) Hope this works! Quote Link to comment Share on other sites More sharing options...
GhostRider Posted November 3, 2008 Share Posted November 3, 2008 Noel, glad you got it working, I actually can't answer your question of "What is the (princ) function?" I don't understand it all myself either, lpseifert and Lee Mac can I'm sure, I follow all their post trying to learn every chance I get... I use commands similar to yours for layer control also my lisp is set up as I posted, though I have all those command on my ACAD.lsp file to load everytime, you may want to look into loading yours that way ... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 3, 2008 Share Posted November 3, 2008 Hi guys, A little explanation of "princ" princ is used just to print a line of text on the command line: i.e. (princ "Lee") will just print the text "Lee" on the command line. And so, by finishing the LISP with: (princ) -- there is nothing after the "princ" function therefore: the LISP will print a new line on the command line and so the expression from the last function is suppressed, and so you have what is known as a 'clean exit'. Hope this is helpful in some way Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 4, 2008 Author Share Posted November 4, 2008 Ghost Rider I too am interested in using my acad.lsp file to load the lisps every time. I can't find it though. Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 4, 2008 Author Share Posted November 4, 2008 Cool. That is simple and good to know. Thanks Lee. Quote Link to comment Share on other sites More sharing options...
GhostRider Posted November 4, 2008 Share Posted November 4, 2008 If your have searched and don't have one you can create it and place it in your search path. custom commands and lisp can be loaded all at once. There's alot of discusssion here about customizations if you search. I'm still learning myself.. Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 5, 2008 Author Share Posted November 5, 2008 Try this Noel - it may be why you are receiving 'unknown command': (defun c:s0 () (command "-layer" "s" "0" "")(PRINC)) (defun c:sd () (command "-layer" "s" "dim" "")(PRINC)) Hope this works! LeeMac, I tried your code and it worked! Thanks so much. I don't understand how your code was different than mine though. But yours does not produce the error Regards Noel Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 5, 2008 Share Posted November 5, 2008 Hi Noel, Your code was slightly different in the fact that it had a few too many "" terms. And so AutoCAD was trying to repeat the last command before finishing what it was doing (as if the user had hit enter too many times). Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 5, 2008 Author Share Posted November 5, 2008 I see that now. Such a simple mistake. 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.