home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 168.img / ACAD3.ZIP / SETUP.LSP < prev    next >
Lisp/Scheme  |  1988-06-20  |  3KB  |  100 lines

  1. ;
  2. ;+-------------------------------------------------------------------------+
  3. ;| SETUP.LSP                                                               |
  4. ;| Ver.  1.0  Feb. 25, 1986                                                |
  5. ;|                                                                         |
  6. ;| J.J.K.     Feb. 25, 1986                                                |
  7. ;|                                                                         |
  8. ;| C.L.H      Nov. 29, 1987   Added error routine and input checking.      |
  9. ;|                                                                         |
  10. ;| This program will set the Units and Limits of a new drawing, and will   |
  11. ;| draw a border line around the drawing.                                  |
  12. ;+-------------------------------------------------------------------------+
  13. ;
  14. ;
  15. (vmon)
  16. (defun seterr (s)                     ;define an error handler
  17.  (if (/= s "Function cancelled")
  18.      (princ (strcat "\nError: " s))
  19.  )
  20.  (menucmd "S=S")
  21.  (setvar "cmdecho" oce)               ;restore previous cmdecho value
  22.  (setvar "lunits" olu)                ;restore previous linear units value
  23.  (setq *error* oer                    ;restore previous error handler
  24.        seterr  nil )
  25.  (princ)
  26. )
  27.  
  28. (apply '(lambda (/ a b d cx cy xl yl oer olu oce)
  29.  (setq oce (getvar "cmdecho"))        ;store current cmdecho value
  30.  (setvar "cmdecho" 0)                 ;turn cmdecho off
  31.  (menucmd "S=UNITS")
  32.  (setq
  33.        oer   *error*                  ;store AutoLisp error routine
  34.        *error*  seterr)               ;temporarily replace it
  35.       
  36.  (initget (+ 1 2 4))                  ;no null input, negative or zero values
  37.  
  38.  (setq a (getint "\nSelect the Units from the screen menu: "))
  39.  (menucmd (strcat "S=U" (itoa a)))
  40.  (cond
  41.    (
  42.      (= a 5)
  43.      (setq a 2 d 5)
  44.    )
  45.  )
  46.  (setq olu (getvar "lunits"))         ;store current linear units setting
  47.  (command "setvar" "lunits" a)        ;set linear units to new value
  48.  
  49.  (initget (+ 1 4))                    ;0 ok, but no null or negative values
  50.  
  51.  (setq b (getreal "\nSelect the Scale from the screen menu: "))
  52.  (cond
  53.    (
  54.      (= b 0)
  55.      (progn
  56.       (initget (+ 1 2 4))              
  57.       (setq b (getreal "\nEnter the scale: "))
  58.       (setq b (float b))
  59.      )
  60.    )
  61.  )
  62.  (cond
  63.    (
  64.      (= d 5)
  65.      (menucmd "S=METRIC")
  66.    )
  67.    (T
  68.      (menucmd "S=ENGLISH")
  69.    )
  70.  )
  71.  (initget (+ 1 4))
  72.  (setq cx (getdist "\nSelect the Paper size from the screen menu: "))
  73.  (initget (+ 1 4))
  74.  (setq cy (getdist))
  75.  (cond
  76.    (
  77.      (= cx 0)
  78.      (progn
  79.       (initget (+ 1 2 4))
  80.       (setq cx (getdist "\nEnter the Horizontal Dimension of the paper: "))
  81.       (initget (+ 1 2 4))
  82.       (setq cy (getdist "\nEnter the Vertical Dimension of the paper: "))
  83.      )
  84.    )
  85.  )
  86.  (setq xl (* b cx) yl (* b cy))
  87.  (command
  88.   "limits" "0,0" (list xl yl)
  89.   "insert" "border" "0,0" xl yl "0"
  90.   "zoom" "a"
  91.  )
  92.  (menucmd "S=S")
  93.  (setvar "cmdecho" oce)               ;restore previous value for cmdecho
  94.  (setq *error* oer                    ;restore previous error handler
  95.        seterr  nil )
  96.  (princ)
  97. )
  98. '()
  99. )
  100.