NoelStalker Posted October 30, 2008 Posted October 30, 2008 Hello everyone, I would like to create an array for different zoom scales. Currently, here is the code I have typed manually in nominal scales by 5 (see below). However, I would like to be able to create a keyboard command for any zoom scale but that would take forever to type out. I don't really understand the language that is being used for lisp files but I know that you can create arrays in other languages to do such a thing as this (i.e. web design). (defun c:z1 () (command "zoom" "s" "1/1xp") ) (defun c:z5 () (command "zoom" "s" "1/5xp") ) (defun c:z10 () (command "zoom" "s" "1/10xp") ) (defun c:z15 () (command "zoom" "s" "1/15xp") ) (defun c:z20 () (command "zoom" "s" "1/20xp") ) (defun c:z25 () (command "zoom" "s" "1/25xp") ) (defun c:z30 () (command "zoom" "s" "1/30xp") ) (defun c:z35 () (command "zoom" "s" "1/35xp") ) Quote
Lee Mac Posted October 30, 2008 Posted October 30, 2008 Only typed this one up quickly, but may be of some use: (defun c:zs (/ sc sc1) (setvar "cmdecho" 0) (setq sc (getint "Specify Scale Factor: 1/")) (setq sc1 (strcat "1/" (rtos sc) "xp")) (command "_zoom" "S" sc1 ) ; end zoom (setvar "cmdecho" 1) (prompt "\nZoom Complete. ") (princ) ) Quote
rkmcswain Posted October 30, 2008 Posted October 30, 2008 If you want the actual function names like Z1, Z2, Z3, etc., then give this a shot. This will create functions Z1 through Z100 (setq i 1) (while (<= i 100) (eval (read (strcat "(defun c:Z" (itoa i) (chr 40)(chr 41) "(command \"._zoom\" \"1" (chr 47) (itoa i) "XP\"))"))) (setq i (1+ i)) ) Quote
NoelStalker Posted October 30, 2008 Author Posted October 30, 2008 Thanks LeeMac, that is exactly what I need and now I know how to make an array. rkmcswain, that is a cool, creative way of doing it without the need for an array. It wouldn't work though, when I put in a number, it asked for xp and when I put in xp it said that it expected an integer value. Thanks for both of your help and have a great day! Sincerely, Noel Quote
rkmcswain Posted October 30, 2008 Posted October 30, 2008 rkmcswain, that is a cool, creative way of doing it without the need for an array. It wouldn't work though, when I put in a number, it asked for xp and when I put in xp it said that it expected an integer value. Hmmm... Works fine here... Command: [b]4[/b] ._zoom Specify corner of window, enter a scale factor (nX or nXP), or [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: [b]1/4XP[/b] Command: Command: [b]16[/b] ._zoom Specify corner of window, enter a scale factor (nX or nXP), or [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: [b]1/16XP[/b] Command: Command: [b]88[/b] ._zoom Specify corner of window, enter a scale factor (nX or nXP), or [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: [b]1/88XP[/b] Command: Quote
NoelStalker Posted November 5, 2008 Author Posted November 5, 2008 ah, rkmcswain, now I see how your program works. I thought that I had to type z2, z8, z12, etc. but you make the number the command. Thanks for your input. 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.