Steven P Posted 12 hours ago Posted 12 hours ago (edited) 13 hours ago, mhupp said: Tho that is pretty cool way to set a bunch of variables with lambda Just for fun, a slight different way to set variables, I like the dotted pair listing to tie in variable name and its short description. Could be expanded as basic lists with the last item being the 'get' function (string, int, distance....) for different types using read and eval [ (list "ard" "Approach Radius" "getDist") ] (defun c:setvariables ( / acount ard crd erd aof eof ) (setq VariablesList (list (cons "ard" "Approach Radius") (cons "crd" "Center Radius") (cons "erd" "End Radius") (cons "aof" "Approach Offset") (cons "eof" "Tie In Offet") )) ; end list, end setq (foreach n VariablesList (setq MyX (getDist (strcat "\nSet " (cdr n) ": "))) (eval (read (strcat "(setq " (car n) " " (vl-princ-to-string MyX) ")" ))) ) ; end foreach ) (defun c:setvariables ( / acount ard crd erd aof eof ) (setq VariablesList (list (list "ard" "Approach Radius" "getdist") (list "crd" "Center Radius" "getdist") (list "erd" "End Radius" "getdist") (list "aof" "Approach Offset" "getdist") (list "eof" "Tie In Offet" "getdist") )) ; end list, end setq (foreach n VariablesList (setq MyX ( (eval (read (last n))) (strcat "\nSet " (cadr n) ": "))) (eval (read (strcat "(setq " (car n) " " (vl-princ-to-string MyX) ")" ))) (if (= (last n) "getstring") ; fix for strings (eval (read (strcat "(setq " (car n) " \"" (vl-princ-to-string MyX) "\")" ))) ) ) ; end foreach ) Couple of edits for typos Edited 12 hours ago by Steven P 1 Quote
pallas Posted 10 hours ago Posted 10 hours ago Thank you for your help. I managed to figure out where I was doing it wrong (I defined the values after the point where they were already used/called upon, didn't notice, so it was a simple matter or moving it higher, to the start of the code). The LISP does what I need it to do now, however I did encounter some issues with extreme cases, like a sharp angle (couple of degree) between the two lines/tangents - comment for future users 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.