Author Topic: Modifying zoomscale for dimscale, etc setup  (Read 5912 times)

0 Members and 1 Guest are viewing this topic.

Anonymous

  • Guest
Modifying zoomscale for dimscale, etc setup
« on: September 09, 2004, 08:11:30 AM »
I found this code from another posting. How could this be modified to do a drawing setup rather than a zoomscale factor. Example......linetype scale, dimscale, etc. If someone could show me one line modified I could do the rest...thanks


Code: [Select]
//zooms to precise paper space scales

zp : dialog {
   label = "Zoom scale";
   : boxed_column {
      label = "zoom ps";
      : list_box {
         allow_accept = true;
         key = "zoom";
         list = " \n1/128\"=1'-0\"\n1/64\"=1'-0\"\n1/32\"=1'-0\"\n1/16\"=1'-0\"\n3/32\"=1'-0\"\n1/8\"=1'-0\"\n3/16\"=1'-0\"\n1/4\"=1'-0\"\n3/8\"=1'-0\"\n1/2\"=1'-0\"\n3/4\"=1'-0\"\n1\"=1'-0\"\n3\"=1'-0\"\n6\"=1'-0\"\nExtents\nPrevious\nAll\nVmax\n.9x\n2x\n.5x";
         width = 5;
         }
         }
         ok_cancel;
         }

Code:
(defun c:zg ()
     (setq zoomfactor "0")
     (setq zdialog (load_dialog "zoomscale"))
     (if (and zdialog (new_dialog "zp" zdialog))
     (progn
          (action_tile "zoom" "(setq zoomfactor $value)")
          (start_dialog)
          (cond
          ((= "0" zoomfactor)
          )
          ((= "1" zoomfactor)
           (setq zoomfactor "0")
           (command ".zoom" "1/1536xp") ;1/128"=1'-0"
          )
          ((= "2" zoomfactor)
           (setq zoomfactor "1")
           (command ".zoom" "1/768xp") ;1/64"=1'-0"
          )
          ((= "3" zoomfactor)
           (command ".zoom" "1/384xp") ;1/32"=1'-0"
          )
          ((= "4" zoomfactor)
           (command ".zoom" "1/192xp") ;1/16"=1'-0"
          )
          ((= "5" zoomfactor)
           (command ".zoom" "1/128xp") ;3/32"=1'-0"
          )
          ((= "6" zoomfactor)
           (command ".zoom" "1/96xp") ;1/8"=1'-0"
          )
          ((= "7" zoomfactor)
           (command ".zoom" "1/64xp") ;3/16"=1'-0"
          )
          ((= "8" zoomfactor)
           (command ".zoom" "1/48xp") ;1/4"=1'-0"
          )
          ((= "9" zoomfactor)
           (command ".zoom" "1/32xp") ;3/8"=1'-0"
          )
          ((= "10" zoomfactor)
           (command ".zoom" "1/24xp") ;1/2"=1'-0"
          )
          ((= "11" zoomfactor)
           (command ".zoom" "1/16xp") ;3/4"=1'-0"
          )
          ((= "12" zoomfactor)
           (command ".zoom" "1/12xp") ;1"=1'-0"
          )
          ((= "13" zoomfactor)
           (command ".zoom" "1/4xp") ;3"=1'-0"
          )
          ((= "14" zoomfactor)
           (command ".zoom" "1/2xp") ;6"=1'-0"
          )
          ((= "15" zoomfactor)
           (command ".zoom" "e") ;extents
          )
          ((= "16" zoomfactor)
           (command ".zoom" "p") ;previous
          )
          ((= "17" zoomfactor)
           (command ".zoom" "a") ;all
          )
          ((= "18" zoomfactor)
           (command ".zoom" "v") ;vmax
          )
          ((= "19" zoomfactor)
           (command ".zoom" ".9x") ;.9x
          )
          ((= "20" zoomfactor)
           (command ".zoom" "2x") ;double scale
          )
          ((= "21" zoomfactor)
           (command ".zoom" ".5") ;half scale
          )
          ) ;_ cond
               ;(alert zoomfactor)
     ) ;_ progn
     ) ;_ if
) ;_ defun

sinc

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #1 on: September 09, 2004, 08:27:35 AM »
Well, I doubt you'd want to modify THAT...  It's a pretty good example of bad programming.  The two-page cond statement is pretty ugly.  :)

TJAM51

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #2 on: September 09, 2004, 08:33:10 AM »
I spotted this because of it's DCL file when invoked was very simple and clean. Is there any other dcl files with an associated lisp routine that would allow me to do what I seek?



Thanks

daron

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #3 on: September 09, 2004, 08:37:47 AM »
Thanks Sinc. I wrote that before 2002 came out with the viewports toolbar for zooming in paperspace. I also wrote it before I understood reusable code with arguments. It works, though I don't have any interest in trying to figure out what "guest" wants, but with your "bad programming" remark, I am curious to see if I can make it better for what it is.

TJAM51

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #4 on: September 09, 2004, 08:40:35 AM »
This is TJAM51. I am sorry.....too early in the morning....not quite woke up yet. I am seeking a simple method of that would be presented like this file that would allow me to click on the scale called out in the DCL file and rather than zooming do a complete setup, like the linetype scale, dimscale, etc......



Thanks

daron

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #5 on: September 09, 2004, 08:45:15 AM »
Ah, I think I understand. I might look into it if I get to updating the code.

sinc

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #6 on: September 09, 2004, 08:46:52 AM »
I just saw that, and had a flashback to one time when my boss at JPL (a definite non-programmer) wrote a csh program with a 7-page if-then-elif statement...  :shock:

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Modifying zoomscale for dimscale, etc setup
« Reply #7 on: September 09, 2004, 09:02:58 AM »
Well speaking on the "quality of the code" i would have to say that i wouldnt call that "bad" perse. It looks like someone new to lisp or new to conditional testing statments wrote it. ...Besides it reads ok. :lol: I can bet that preforming maintence on it cant be that hard. :P

HOWEVER i do see code like this (for people new to lisp, or those ignorant...) as a must! It definatly drives the point home of redundant code and makes the subject of suport procedures an easier pill to swallow.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Modifying zoomscale for dimscale, etc setup
« Reply #8 on: September 09, 2004, 09:08:43 AM »
I have deleted the other post on this subject TJAM51. Now there shouldnt be any confusion. (Answers in both posts.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Modifying zoomscale for dimscale, etc setup
« Reply #9 on: September 09, 2004, 10:11:51 AM »
Ok, since the "quality" of the code was called into question.... I have taken the liberty of condensing it a bit....

LISP Code
Code: [Select]

(defun c:zg ()
  (setq zdialog (load_dialog "zoomscale"))
  (if (and zdialog (new_dialog "zp" zdialog))
    (progn
      (action_tile "zoom" "(setq zoomfactor (atoi $value))")
      (if (>(start_dialog) 0)
        (command ".zoom" (nth zoomfactor (list "1/1536xp" "1/768xp" "1/384xp" "1/192xp" "1/128xp" "1/96xp"
                                "1/64xp" "1/48xp" "1/32xp" "1/24xp" "1/16xp" "1/12xp" "1/4xp"
              "1/2xp" "e" "p" "a" "v" ".9x" "2x" ".5")))
      )
    ) ;_ progn
  ) ;_ if
)


DCL Code
Code: [Select]

zp : dialog {
   label = "Zoom scale";
   : boxed_column {
      label = "zoom ps";
      : list_box {
         allow_accept = true;
         key = "zoom";
         list = "1/128\"=1'-0\"\n1/64\"=1'-0\"\n1/32\"=1'-0\"\n1/16\"=1'-0\"\n3/32\"=1'-0\"\n1/8\"=1'-0\"\n3/16\"=1'-0\"\n1/4\"=1'-0\"\n3/8\"=1'-0\"\n1/2\"=1'-0\"\n3/4\"=1'-0\"\n1\"=1'-0\"\n3\"=1'-0\"\n6\"=1'-0\"\nExtents\nPrevious\nAll\nVmax\n.9x\n2x\n.5x";
         width = 5;
      }
   }
   ok_cancel;
   }


In an effort to correctly design a program you would need to let us know exactly how you want to setup your drawings. I am confused as are probably many of the others here as to what exactly you are looking for.

This code in itself is probably not the best way to handle multiple settings. The dialog would work ok, but the number of system variables you want to change would make a big difference.
For example in the above code, if you only wanted to change one setting, you could change the line where it calls the zoom command to one that sets the variable you want changed, adjust the list to the settings you require for each of your scale factors.
If you were to use multiple variables and want to change them all, a much easier way to handle it would be the mapcar function...
i.e.
Code: [Select]

(mapcar 'setvar '(variable name list) '(variable argument list))

The length of the name list and argument list must be the same
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

TJAM51

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #10 on: September 09, 2004, 10:27:27 AM »
The setup would include the dimscale and linetype scale variables. iF possible load a routine that sets up the layers.....



Thanks

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Modifying zoomscale for dimscale, etc setup
« Reply #11 on: September 09, 2004, 10:31:33 AM »
TJ, Did you get my PM?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

TJAM51

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #12 on: September 09, 2004, 10:37:54 AM »
Did not receive PM

daron

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #13 on: September 10, 2004, 09:06:09 AM »
Quote from: Se7en
HOWEVER i do see code like this (for people new to lisp, or those ignorant...)


Thanks, and yes, it was written when I was new to code. Thanks for calling me ignorant. I suppose everyone's ignorant when they're new to something, hey?

TJAM51

  • Guest
Modifying zoomscale for dimscale, etc setup
« Reply #14 on: September 10, 2004, 09:17:51 AM »
Ahhh gentleman.....how 'bout what is the correct way to replace the zoom scale commands with something more like dimscale and linetype scale setup....... :D

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Modifying zoomscale for dimscale, etc setup
« Reply #15 on: September 10, 2004, 09:29:11 AM »
Quote from: Daron
Thanks, and yes, it was written when I was new to code. Thanks for calling me ignorant. I suppose everyone's ignorant when they're new to something, hey?
*blink* ...Daron?! Do you want me to change that word to dumb?



If you feel that i insulted you, look up the word then spend the rest of the day bangin' your head on the table so no one can truthfully call you ignorant again.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org