Nikon Posted December 30, 2023 Author Posted December 30, 2023 @BIGAL Thanks for the help. 6 hours ago, BIGAL said: (defun c:11 ( / ..... ..... .. ) (c:11) As I understand it, lisps with this ending (c:11) should not be in the startup, otherwise (if there are 10-20 pieces. - they will all immediately start executing this commands) there will be confusion... or am I wrong in my assumption? Quote
Steven P Posted December 30, 2023 Posted December 30, 2023 That's right, if there is a stand alone line of code in the LISP (not enclosed by (defun ...... ) then that will be executed as the LISP loads. If the file only contains a single LISP then loading the file on demand as discussed above will run the LISP. You can delete this or comment it out (with ;; )in the file you have saved if it is more convenient. For example, I have a start up LISP file and in this there are lines, outside of a function, that sets the system to my preferences, so it is the same each time I load a drawing rather than whatever it was last time I closed one, this functionality has its uses. 1 Quote
Nikon Posted January 1, 2024 Author Posted January 1, 2024 (edited) Happy New Year to all Is it possible to slightly change lisp "11" so that the line at an angle (minus) (anglevalue) does not go under the X axis? (defun c:11 (/ p0 ang dist) (defun 11error (errormsg /) (setvar "SNAPANG" old_snapang) ; reset variables (setvar "ORTHOMODE" old_orthomode) (setq *error* temperr) ; reset *error* (prompt "\nFunction Canelled.") ) (vl-load-com) (setq p0 (getpoint "Pick the first point >") ang (angtof (rtos (getreal "Enter angle >")) 0) ) (setq Old_snapang (getvar "SNAPANG")) ; to record what it was, might not be 0 (setq old_orthomode (getvar "ORTHOMODE")) (setq temperr *error*) ;store *error* ; can wait till here to set error function, after recording old variables (setq *error* 11error) (setvar "SNAPANG" ang) (setvar "ORTHOMODE" 1) (setq dist (distance p0 (getpoint p0 "Pick a second point >"))) (setvar "SNAPANG" Old_Snapang) ; moved this here, seto to old value (no assumption what it was) (setvar "ORTHOMODE" old_orthomode) (entmakex (list (cons 0 "LINE") (cons 10 p0) (cons 11 (polar p0 ang dist)))) (setq *error* temperr) ; reset error (princ) ) Edited January 7, 2024 by Nikon Quote
1958 Posted January 1, 2024 Posted January 1, 2024 2 hours ago, Nikon said: Happy New Year to all Is it possible to slightly change lisp "11" so that the line at an angle (minus) (anglevalue) does not go under the X axis? Prohibition of entering a negative value (defun c:11 (/ p0 ang dist) (defun 11error (errormsg /) (setvar "SNAPANG" old_snapang) ; reset variables (setvar "ORTHOMODE" old_orthomode) (setq *error* temperr) ; reset *error* (prompt "\nFunction Canelled.") ) (vl-load-com) (setq p0 (getpeint "Pick the first point >")) (initget 4) ; Entering negative numbers is not allowed (setq ang (angtof (rtos (getreal "Enter angle >")) 0)) (setq Old_snapang (getvar "SNAPANG")) ; to record what it was, might not be 0 (setq old_orthomode (getvar "ORTHOMODE")) (setq temperr *error*) ;store *error* ; can wait till here to set error function, after recording old variables (setq *error* 11error) (setvar "SNAPANG" ang) (setvar "ORTHOMODE" 1) (setq dist (distance p0 (getpoint p0 "Pick a second point >"))) (setvar "SNAPANG" Old_Snapang) ; moved this here, seto to old value (no assumption what it was) (setvar "ORTHOMODE" old_orthomode) (entmakex (list (cons 0 "LINE") (cons 10 p0) (cons 11 (polar p0 ang dist)))) (setq *error* temperr) ; reset error (princ) ) 1 Quote
Steven P Posted January 1, 2024 Posted January 1, 2024 Yes, use 'abs' where you enter the angle. Will let you have a go to work it out https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-3AF854D7-9B75-4A4B-ABA4-E47DB90FB2F6 Quote
1958 Posted January 1, 2024 Posted January 1, 2024 4 minutes ago, Steven P said: Yes, use 'abs' where you enter the angle. Will let you have a go to work it out (defun c:11 (/ p0 ang dist) (defun 11error (errormsg /) (setvar "SNAPANG" old_snapang) ; reset variables (setvar "ORTHOMODE" old_orthomode) (setq *error* temperr) ; reset *error* (prompt "\nFunction Canelled.") ) (vl-load-com) (setq p0 (getpoint "Pick the first point >") ang (angtof (rtos (abs (getreal "Enter angle >"))) 0) ) (setq Old_snapang (getvar "SNAPANG")) ; to record what it was, might not be 0 (setq old_orthomode (getvar "ORTHOMODE")) (setq temperr *error*) ;store *error* ; can wait till here to set error function, after recording old variables (setq *error* 11error) (setvar "SNAPANG" ang) (setvar "ORTHOMODE" 1) (setq dist (distance p0 (getpoint p0 "Pick a second point >"))) (setvar "SNAPANG" Old_Snapang) ; moved this here, seto to old value (no assumption what it was) (setvar "ORTHOMODE" old_orthomode) (entmakex (list (cons 0 "LINE") (cons 10 p0) (cons 11 (polar p0 ang dist)))) (setq *error* temperr) ; reset error (princ) ) 1 Quote
Nikon Posted January 1, 2024 Author Posted January 1, 2024 (edited) @1958 & @Steven PThank you and happy new year! This last code draws a line at an angle (-60) to the right side, if you set the angle (-30), then the dotted line shows the Angle (-60), and the line turns to the right side (30)... Edited January 1, 2024 by Nikon Quote
1958 Posted January 1, 2024 Posted January 1, 2024 You enter the angle value - 30 degrees to the 0-X axis, and move the cursor to the floor at an angle of 120 degrees. Paradox! 1 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.