Jump to content

Recommended Posts

Posted

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

)

Posted

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

Posted

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

Posted

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

Posted

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:

Posted

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.

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