NoelStalker Posted November 10, 2008 Posted November 10, 2008 I had some help making an array to make commands z1-z100 which would set the zoom scale accordingly. I started with that code and tried to make commands d1-d100 that would allow me to change the dimscale. I think I don't understand how the array works with this language. What is "itoa" and why do chr 40, 41 and 47 show up in the array? (setq i 1) (while (<= i 100) (eval (read (strcat "(defun c:D" (itoa i) (chr 40)(chr 41) "(command \"dimscale\" \"1" (chr 47) (itoa i) ))"))) (setq i (1+ i)) ) Quote
ASMI Posted November 10, 2008 Posted November 10, 2008 There is no any array of commands. An array is indexed list or matrix. Arrays are rather seldom used in LISP because it is language of lists (not indexed, associative lists). You try to create 100 user functions (programs). This one of possibilities LISP not possible in other languages. The program itself writes a code which can execute at once. (defun c:test(/ i) (setq i 1) (repeat 100 (eval(read(strcat "(defun c:d" (itoa i) "()(setvar \"DIMSCALE\" " (itoa i) ")(princ))"))) (setq i(1+ i)) ); end repeat (princ) ); end of c:test Functions d1 - d100 creation. Quote
Lee Mac Posted November 11, 2008 Posted November 11, 2008 Again, like ASMI said, there are no array functions, but maybe this would help? (defun c:dd (/ dim1) (setq dim1 (getint "\nSpecify Dimscale: D")) (setvar "Dimscale" dim1) (princ (strcat "<< Dimscale Set to " (rtos (getvar "dimscale")) " >>")) (princ) ) ; end dd Hope this Helps! PS. FYI "itoa" converts Integer to String. "chr" returns the conversion of ASCII character code into text ~ in this case (chr 40), (chr 41) and (chr 47) are "(" , ")" and "/" respectively. Quote
NoelStalker Posted November 11, 2008 Author Posted November 11, 2008 ASMI, Thanks for the clarification. I tried this lisp, loaded it and then typed D20 as a test. It did not work. Am I missing something from your response? Command: d20 Unknown command "D20". Press F1 for help. Quote
Lee Mac Posted November 11, 2008 Posted November 11, 2008 Hi Noel, With ASMI's code, you will need to load it, and type "test" to create a set of 100 programs, after typing test, you can then type "d20" etc to set dimscale. Quote
NoelStalker Posted November 11, 2008 Author Posted November 11, 2008 LeeMac, Thanks for the explanation. Can I put "test" somewhere in the lisp so I don't have to type it every time I open ACAD? I tried putting test here and it did not work... (defun c:test(/ i) (setq i 1) (repeat 100 (eval(read(strcat "(defun c:d" (itoa i) "()(setvar \"DIMSCALE\" " (itoa i) ")(princ))"))) (setq i(1+ i)) ); end repeat (princ) ); end of c:test test Quote
ASMI Posted November 11, 2008 Posted November 11, 2008 If you need autorun: (defun c:test(/ i) (setq i 1) (repeat 100 (eval(read(strcat "(defun c:d" (itoa i) "()(setvar \"DIMSCALE\" " (itoa i) ")(princ))"))) (setq i(1+ i)) ); end repeat (princ) ); end of test [color="Blue"](c:test)[/color] Quote
NoelStalker Posted November 11, 2008 Author Posted November 11, 2008 ASMI. Great thanks so much. That is pretty straight forward. I will remember that and probably use it again in the future. 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.