home *** CD-ROM | disk | FTP | other *** search
- ;;; 3DARRAY.LSP
- ;;;
- ;;; ¬⌐┼v (C) 1987-1992 Autodesk ñ╜Ñq
- ;;;
- ;;; Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
- ;;; ¡∞½h :
- ;;;
- ;;; 1) ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
- ;;; 2) ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
- ;;;
- ;;; Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
- ;;; Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
- ;;;
- ;;;
- ;;; Functions included:
- ;;; 1) Rectangular ARRAYS (rows, columns & levels)
- ;;; 2) Circular ARRAYS around any axis
- ;;;
- ;;; All are loaded by: (load "3darray")
- ;;;
- ;;; And run by:
- ;;; Command: 3darray
- ;;; Select objects:
- ;;; Rectangular or Polar array (R/P): (select type of array)
- ;;;***********************************************************************
- ;;; ===========================================================================
- ;;; ===================== load-time error checking ============================
- ;;;
-
- (defun ai_abort (app msg)
- (defun *error* (s)
- (if old_error (setq *error* old_error))
- (princ)
- )
- (if msg
- (alert (strcat " Application error: "
- app
- " \n\n "
- msg
- " \n"
- )
- )
- )
- (exit)
- )
-
- ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
- ;;; and then try to load it.
- ;;;
- ;;; If it can't be found or it can't be loaded, then abort the
- ;;; loading of this file immediately, preserving the (autoload)
- ;;; stub function.
-
- (cond
- ( (and ai_dcl (listp ai_dcl))) ; it's already loaded.
-
- ( (not (findfile "ai_utils.lsp")) ; find it
- (ai_abort "3DARRAY"
- (strcat "Can't locate file AI_UTILS.LSP."
- "\n Check support directory.")))
-
- ( (eq "failed" (load "ai_utils" "failed")) ; load it
- (ai_abort "3DARRAY" "Can't load file AI_UTILS.LSP"))
- )
-
- (if (not (ai_acadapp)) ; defined in AI_UTILS.LSP
- (ai_abort "3DARRAY" nil) ; a Nil <msg> supresses
- ) ; ai_abort's alert box dialog.
-
- ;;; ==================== end load-time operations ===========================
- ;;;
- ;;;******************************** MODES ********************************
- ;;;
- ;;; System variable save
-
- (defun MODES (a)
- (setq MLST '())
- (repeat (length a)
- (setq MLST (append MLST (list (list (car a) (getvar (car a))))))
- (setq a (cdr a))
- )
- )
-
- ;;;******************************** MODER ********************************
- ;;;
- ;;; System variable restore
-
- (defun MODER ()
- (repeat (length MLST)
- (setvar (caar MLST) (cadar MLST))
- (setq MLST (cdr MLST))
- )
- )
-
- ;;;******************************** 3DAERR *******************************
- ;;;
- ;;; Standard error function
-
- (defun 3DAERR (st) ; If an error (such as CTRL-C) occurs
- ; while this command is active...
- (if (/= st "íu¿τ╝╞ív¿·«°")
- (princ (strcat "\n┐∙╗~: " s))
- )
- (command "_.UNDO" "_E")
- (ai_undo_off)
- (moder) ; Restore system variables
- (setq *error* olderr) ; Restore old *error* handler
- (princ)
- )
-
- ;;;******************************* P-ARRAY *******************************
- ;;;
- ;;; Perform polar (circular) array around any axis
-
- (defun P-ARRAY (/ n af yn cen c ra)
-
- ;; Define number of items in array
- (setq n 0)
- (while (<= n 1)
- (initget (+ 1 2 4))
- (setq n (getint "\n╜╞╗s╝╞╢q: "))
- (if (= n 1)
- (prompt "\n╜╞╗s╝╞╢qÑ▓╢╖ > 1")
- )
- )
-
- ;; Define angle to fill
- (initget 2)
- (setq af (getreal "\n╣w│╞ñ└ºG¬║¿ñ½╫ <360>: "))
- (if (= af nil) (setq af 360))
-
- ;; Are objects to be rotated?
- (initget "Yes No")
- (setq yn (getkword "\n¬½┼Θ½÷╖╙╜╞╗s½ß¬║¿ñ½╫íu▒█┬αív? <Y>: "))
- (if (null yn)
- (setq yn "Y")
- )
-
- ;; Define center point of array
- (initget 17)
- (setq cen (getpoint "\níu└⌠º╬░}ªCívñññ▀┬I: "))
- (setq c (trans cen 1 0))
-
- ;; Define rotational axis
- (initget 17)
- (setq ra (getpoint cen "\n▒█┬╢╢bíu▓─ 2 ┬Iív: "))
- (while (equal ra cen)
- (princ "\n┬Iª∞╡L«─; ▓─ 2 ┬IñúÑi╡Ñ⌐≤íuñññ▀┬IívíC")
- (initget 17)
- (setq ra (getpoint cen "\n╜╨ªA╕╒: "))
- )
- (setvar "UCSFOLLOW" 0)
- (setvar "GRIDMODE" 0)
- (command "_.UCS" "_ZAXIS" cen ra)
- (setq cen (trans c 0 1))
-
- ;; Draw polar array
- (command "_.ARRAY" ss "" "_P" cen n af yn)
- (command "_.UCS" "_p")
- )
-
- ;;;******************************* R-ARRAY *******************************
- ;;;
- ;;; Perform rectangular array
-
- (defun R-ARRAY (/ nr nc nl flag x y z c el en ss2 e)
-
- ;; Set array parameters
- (while (or (= nr nc nl nil) (= nr nc nl 1))
- (setq nr 1)
- (initget (+ 2 4))
- (setq nr (getint "\n╛εªC╝╞ (---) <1>: "))
- (if (null nr) (setq nr 1))
- (initget (+ 2 4))
- (setq nc (getint "\n¬╜ªµ╝╞ (|||) <1>: "))
- (if (null nc) (setq nc 1))
- (initget (+ 2 4))
- (setq nl (getint "\n╝h╢Ñ╝╞ (...) <1>: "))
- (if (null nl) (setq nl 1))
- (if (= nr nc nl 1)
- (princ "\níu│µñ@ñ╕┼Θív░}ªC, ñúñ⌐░⌡ªµíC\n╜╨ªA╕╒")
- )
- )
- (setvar "ORTHOMODE" 1)
- (setvar "HIGHLIGHT" 0)
- (setq flag 0) ; Command style flag
- (if (/= nr 1)
- (progn
- (initget (+ 1 2))
- (setq y (getdist "\n╛εªC╢í╢Z (---): "))
- (setq flag 1)
- )
- )
- (if (/= nc 1)
- (progn
- (initget (+ 1 2))
- (setq x (getdist "\n¬╜ªµ╢í╢Z (|||): "))
- (setq flag (+ flag 2))
- )
- )
- (if (/= nl 1)
- (progn
- (initget (+ 1 2))
- (setq z (getdist "\n╝h╢Ñ╢í╢Z (...): "))
- )
- )
- (setvar "BLIPMODE" 0)
-
- (setq c 1)
- (setq el (entlast)) ; Reference entity
- (setq en (entnext el))
- (while (not (null en))
- (setq el en)
- (setq en (entnext el))
- )
-
- ;; Copy the selected entities one level at a time
- (while (< c nl)
- (command "_.COPY" ss "" "0,0,0" (append (list 0 0) (list (* c z)))
- )
- (setq c (1+ c))
- )
-
- (setq ss2 (ssadd)) ; create a new selection set
- (setq e (entnext el)) ; of all the new entities since
- (while e ; the reference entity.
- (ssadd e ss2)
- (setq e (entnext e))
- )
-
- ;; Array original selection set and copied entities
- (cond
- ((= flag 1) (command "_.ARRAY" ss ss2 "" "_R" nr "1" y))
- ((= flag 2) (command "_.ARRAY" ss ss2 "" "_R" "1" nc x))
- ((= flag 3) (command "_.ARRAY" ss ss2 "" "_R" nr nc y x))
- )
- )
-
- ;;;***************************** MAIN PROGRAM ****************************
-
- (defun C:3DARRAY (/ olderr ss xx undo_setting)
- (if (and (= (getvar "cvport") 1) (= (getvar "tilemode") 0))
- (progn
- (prompt "\n *** íu╣╧»╚¬┼╢íívñUñúñ╣Ñ╬ª╣½ⁿÑO ***\n")
- (princ)
- )
- (progn
- (setq olderr *error*
- *error* 3daerr
- )
- (modes '("cmdecho" "blipmode" "highlight" "orthomode"
- "ucsfollow" "gridmode")
- )
- (setvar "CMDECHO" 0)
-
- (ai_undo_on) ; Turn UNOD on
-
- (command "_.UNDO" "_GROUP")
- (graphscr)
-
- (setq ss nil)
- (while (null ss) ; Ensure selection of entities
- (setq ss (ssget))
- )
-
- (initget 1 "Rectangular Polar Circular")
- (setq xx (getkword "\níuR»xº╬ív⌐╬íuP└⌠º╬ív░}ªC (R/P): "))
- (cond
- ((eq xx "Rectangular")
- (r-array)
- )
- (T
- (p-array)
- )
- )
- (command "_.UNDO" "_E")
- (ai_undo_off) ; Return UNDO to initial state
- (moder) ; Restore system variables
- (setq *error* olderr) ; Restore old *error* handler
- (princ)
- )
- )
- )
-
- (princ " íu3DARRAYívñw╕ⁿñJíC")
- (princ)