home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p065 / 4.img / 3DARRAY.LSP next >
Encoding:
Text File  |  1992-01-08  |  5.0 KB  |  188 lines

  1. ;******************************** MODES ********************************
  2.  
  3. ; System variable save
  4.  
  5. (VMON)
  6.  
  7. (defun MODES (a)
  8.    (setq MLST '())
  9.    (repeat (length a)
  10.       (setq MLST (append MLST (list (list (car a) (getvar (car a))))))
  11.       (setq a (cdr a)))
  12. )
  13.  
  14. ;******************************** MODER ********************************
  15.  
  16. ; System variable restore
  17.  
  18. (defun MODER ()
  19.    (repeat (length MLST)
  20.       (setvar (caar MLST) (cadar MLST))
  21.       (setq MLST (cdr MLST))
  22.    )
  23. )
  24.  
  25. ;******************************** 3DAERR *******************************
  26.  
  27. ; Standard error function
  28.  
  29. (defun 3DAERR (st)                    ; If an error (such as CTRL-C) occurs
  30.                                       ; while this command is active...
  31.   (if (/= st "Function cancelled")
  32.       (princ (strcat "\nError: " s))
  33.   )
  34.   (command "UNDO" "E")
  35.   (moder)                             ; Restore system variables
  36.   (setq *error* olderr)               ; Restore old *error* handler
  37.   (princ)
  38. )
  39.  
  40. ;******************************* P-ARRAY *******************************
  41.  
  42. ; Perform polar (circular) array around any axis
  43.  
  44. (defun P-ARRAY (/ n af yn cen c ra)
  45.  
  46.    ; Define number of items in array
  47.    (setq n 0)
  48.    (while (<= n 1)
  49.           (initget (+ 1 2 4))
  50.           (setq n (getint "\n╩Σ╚δ╧ε╩²: "))
  51.           (if (= n 1)
  52.               (prompt "\n╧ε╩²▒╪╨δ┤≤╙┌ 1")
  53.           )
  54.    )
  55.  
  56.    ; Define angle to fill
  57.    (initget 2)
  58.    (setq af (getreal "\n╒≤┴╨╔·│╔╖╢╬º╜╟╢╚ <360>: "))
  59.    (if (= af nil) (setq af 360))
  60.  
  61.    ; Are objects to be rotated?
  62.    (initget "Yes No")
  63.    (setq yn (getkword "\n╒≤┴╨╔·│╔╩▒╨²╫¬╩╡╠σ┬≡ <Y>: "))
  64.    (if (null yn)
  65.       (setq yn "Y")
  66.    )
  67.  
  68.    ; Define center point of array
  69.    (initget 17)
  70.    (setq cen (getpoint "\n╘░╨─: "))
  71.    (setq c (trans cen 1 0))
  72.  
  73.    ; Define rotational axis
  74.    (initget 17)
  75.    (setq ra (getpoint cen "\n╨²╫¬╓ß╡─╡┌╢■╡π: "))
  76.    (while (equal ra cen)
  77.       (princ "\nInvalid point. Second point cannot equal center point.")
  78.       (initget 17)
  79.       (setq ra (getpoint cen "\nPlease try again: "))
  80.    )
  81.    (setvar "UCSFOLLOW" 0)
  82.    (setvar "GRIDMODE" 0)
  83.    (command "UCS" "ZAXIS" cen ra)
  84.    (setq cen (trans c 0 1))
  85.  
  86.    ; Draw polar array
  87.    (command "ARRAY" ss "" "P" cen n af yn)
  88.    (command "UCS" "p")
  89. )
  90.  
  91. ;******************************* R-ARRAY *******************************
  92.  
  93. ; Perform rectangular array
  94.  
  95. (defun R-ARRAY (/ nr nc nl flag x y z c el en ss2 e)
  96.  
  97.    ; Set array parameters
  98.    (while (or (= nr nc nl nil) (= nr nc nl 1))
  99.       (setq nr 1 nc 1)
  100.       (initget (+ 2 4))
  101.       (setq nl (getint "\n▓π╩² (...) <1>: "))
  102.       (if (null nl) (setq nl 1))
  103.       (if (= nr nc nl 1)
  104.          (princ "\nOne-element array, nothing to do.\nPlease try again")
  105.       )
  106.    )
  107.    (setvar "ORTHOMODE" 1)
  108.    (setvar "HIGHLIGHT" 0)
  109.    (setq flag 0)                      ; Command style flag
  110.    (cond ((/= nr 1)
  111.           (initget (+ 1 2))
  112.           (setq y (getdist "\n╨╨╝Σ╛α└δ (---): "))
  113.           (setq flag 1)
  114.          )
  115.    )
  116.    (cond ((/= nc 1)
  117.           (initget (+ 1 2))
  118.           (setq x (getdist "\n┴╨╝Σ╛α└δ (|||): "))
  119.           (setq flag (+ flag 2))
  120.          )
  121.    )
  122.    (cond  ((/= nl 1)
  123.            (initget (+ 1 2))
  124.            (setq z (getdist "\n▓π╕▀ (...): "))
  125.           )
  126.    )
  127.    (setvar "BLIPMODE" 0)
  128.  
  129.    (setq c 1)
  130.    (setq el (entlast))                ; Reference entity
  131.    (setq en (entnext el))
  132.    (while (not (null en))
  133.        (setq el en)
  134.        (setq en (entnext el))
  135.    )
  136.  
  137.    ; Copy the selected entities one level at a time
  138.    (while (< c nl)
  139.           (command "COPY" ss ""
  140.                           "0,0,0"
  141.                           (append (list 0 0) (list (* c z)))
  142.           )
  143.           (setq c (1+ c))
  144.    )
  145.  
  146. ;  (setq ss2 (ssadd))                 ; create a new selection set
  147. ;  (setq e (entnext el))              ; of all the new entities since
  148. ;  (while e                           ; the reference entity.
  149. ;      (ssadd e ss2)
  150. ;      (setq e (entnext e))
  151. ;  )
  152.  
  153.    ; Array original selection set and copied entities
  154.    (cond
  155.      ((= flag 1) (command "ARRAY" ss ss2 "" "R" nr "1" y))
  156.      ((= flag 2) (command "ARRAY" ss ss2 "" "R" "1" nc x))
  157.      ((= flag 3) (command "ARRAY" ss ss2 "" "R" nr nc y x))
  158.    )
  159. )
  160.  
  161. ;***************************** MAIN PROGRAM ****************************
  162.  
  163. (defun C:3DARRAY (/ olderr ss xx)
  164.  
  165.    (setq olderr *error*
  166.          *error* 3daerr)
  167.    (modes '("cmdecho" "blipmode" "highlight" "orthomode" 
  168.             "ucsfollow" "gridmode"))
  169.    (setvar "CMDECHO" 0)
  170.    (command "UNDO" "GROUP")
  171.    (graphscr)
  172.  
  173.    (setq ss nil)
  174.    (while  (null ss)                  ; Ensure selection of entities
  175.            (setq ss (ssget))
  176.    )
  177.  
  178.    (initget 1 "Rectangular Polar Circular")
  179.    (setq xx "Rectangular")
  180.    (cond ((eq xx "Rectangular") (r-array))
  181.          (T (p-array))
  182.    )
  183.    (command "UNDO" "E")
  184.    (moder)                            ; Restore system variables
  185.    (setq *error* olderr)              ; Restore old *error* handler
  186.    (princ)
  187. )
  188.