albroswift Posted October 4, 2014 Share Posted October 4, 2014 (edited) Greetings Project for this weekend learn a thing or 2 about .lsp files. Started down the tutorial http://www.cadtutor.net/tutorials/autolisp/quick-start.php Lots of new language, most of it makes sense, after reading tutorial I tried a couple of the sample scripts. The CHLAYER worked as expected, put file in .../scripts directory, loaded the file, works great and as expected, and is something I can use regularly. Tried the "Change Crosshair Angle" script: (defun c:perpdon (/ a b pntl pnt2 angl) (graphscr) (setq a (entsel)) (setq b (entget (car a))) (setq pntl (cdr (assoc 10 b))) (setq pnt2 (cdr (assoc 11 b))) (setq angl (angle pntl pnt2)) (setvar "snapang" ang1) (princ) ) (defun c:perpdoff (setvar "snapang" 0) (princ) ) Script goes right to select entity, I select a line, then nothing happens. Ortho remains 0/90 Also tried separating the scripts "PERPDON" and "PERPDOFF" as different .lsp files Either way, command "PERPDOFF" always returns "Unknown command press F1 for help" ACAD 2014 Thanks-- AL Edited October 13, 2014 by SLW210 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 4, 2014 Share Posted October 4, 2014 Simple error to fix (), please do code section using the # option or type [ c o d e ] at start [ / c o d e] at end moderator will pick this up. (defun c:perpdoff () (setvar "snapang" 0) Quote Link to comment Share on other sites More sharing options...
albroswift Posted October 5, 2014 Author Share Posted October 5, 2014 Thanks for the instructions on posting code. Tried adding the (), still no joy. tried a couple of other scripts and they work, like to know what is missing here. AL (defun c:perpdon (/ a b pntl pnt2 angl) (graphscr) (setq a (entsel)) (setq b (entget (car a))) (setq pntl (cdr (assoc 10 b))) (setq pnt2 (cdr (assoc 11 b))) (setq angl (angle pntl pnt2)) (setvar "snapang" ang1) (princ) ) (defun c:perpdoff () (setvar "snapang" 0) (princ) ) Quote Link to comment Share on other sites More sharing options...
BKT Posted October 9, 2014 Share Posted October 9, 2014 Thanks for the instructions on posting code. Tried adding the (), still no joy. tried a couple of other scripts and they work, like to know what is missing here.AL (defun c:perpdon (/ a b pntl pnt2 angl) (graphscr) (setq a (entsel)) (setq b (entget (car a))) (setq pntl (cdr (assoc 10 b))) (setq pnt2 (cdr (assoc 11 b))) (setq angl (angle pntl pnt2)) (setvar "snapang" ang1) (princ) ) (defun c:perpdoff () (setvar "snapang" 0) (princ) ) It appears that the code has mixed the numeral "1" with the lower case "L" in the "ang" variable. If you make them consistent this should fix the problem (i.e., use either "ang1" or "angl"). To avoid confusion, it might also be better to set the two "pnt" variables to use either numerals or letters but not one of each. I would use "pnt1" and "pnt2". Currently "pnt1" is actually "pntl" and depending on the font used, it's difficult to see the difference. Quote Link to comment Share on other sites More sharing options...
albroswift Posted October 9, 2014 Author Share Posted October 9, 2014 You are 100% correct. Changing the font makes it very clear. Just edited script and re-loaded and it works as expected. Thanks-- Al Quote Link to comment Share on other sites More sharing options...
BKT Posted October 9, 2014 Share Posted October 9, 2014 Glad I could help! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 10, 2014 Share Posted October 10, 2014 Nice pick up BKT missed that you get used to typing PT1 so dont think to look for typo. Quote Link to comment Share on other sites More sharing options...
BKT Posted October 10, 2014 Share Posted October 10, 2014 Nice pick up BKT missed that you get used to typing PT1 so dont think to look for typo. Thanks, BIGAL - I ran into this same typo a while back and I remember how long it took to find it! Quote Link to comment Share on other sites More sharing options...
albroswift Posted October 10, 2014 Author Share Posted October 10, 2014 Been using cad since the Tandy 3000 was the hot machine and Mr Gore had yet to invent the net. Sure glad he did, having resources like these forums really beats the early BBs. Thanks again for the help. Al 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.