Jump to content

Recommended Posts

Posted

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))
)

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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

Posted

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]

Posted

ASMI. Great thanks so much. That is pretty straight forward. I will remember that and probably use it again in the future.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...