; The Codewriting Workbook ; Creating Computational Architecture in AutoLISP ; by Robert J. Krawczyk ; Princeton Architectural Press, 2008 ; -------------------------------------------------------------------------- ; CH05C.LSP ; -------------------------------------------------------------------------- ; Disclaimer: The information contained in this file is distributed on an ; "as is" basis, without warranty. Although every precaution has been taken ; in the preparation of this work, the author and publisher shall not have ; any liability to any person or entity with respect to any loss or damage ; caused or alleged to be caused directly or indirectly by the information ; contained in this work. ; -------------------------------------------------------------------------- (defun dtr (a) (* pi (/ a 180.0))) (defun rtd (a) (/ (* a 180.0) pi)) (defun tan (a) (/ (sin a) (cos a))) ; -------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ; VT - top view (defun c:vt () (command "vpoint" "r" 270 90) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VL - left view (defun c:vl () (command "vpoint" "r" 180 0) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VR - right view (defun c:vr () (command "vpoint" "r" 0 0) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VF - front view (defun c:vf () (command "vpoint" "r" 270 0) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VB - back view (defun c:vb () (command "vpoint" "r" 90 0) (command "zoom" "e" "ucs" "v" "zoom" ".9x") (princ) ) ; VSW - SW view (defun c:vsw () (command "vpoint" "r" 270 90) (command "ucs" "v") (command "vpoint" "r" 225 45) (command "zoom" "e" "zoom" ".9x") (princ) ) ; VSE - SE view (defun c:vse () (command "vpoint" "r" 270 90) (command "ucs" "v") (command "vpoint" "r" 315 45) (command "zoom" "e" "zoom" ".9x") (princ) ) ; VNE - NE view (defun c:vne () (command "vpoint" "r" 270 90) (command "ucs" "v") (command "vpoint" "r" 45 45) (command "zoom" "e" "zoom" ".9x") (princ) ) ; VNW - NW view (defun c:vnw () (command "vpoint" "r" 270 90) (command "ucs" "v") (command "vpoint" "r" 135 45) (command "zoom" "e" "zoom" ".9x") (princ) ) ;--------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog01 () (graphscr) ; tower polygon section (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get tower parameters (princ "\nProg01 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq Rad (getdist "\nEnter radius: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ NumLevels 1) (+ NumSides 1)) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) (repeat (+ NumSides 1) ; compute point (setq xpt (+ (nth 0 cpnt) (* Rad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* Rad (cos (dtr pang))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog02 () (graphscr) ; tower polygon section ; add bottom and top (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get tower parameters (princ "\nProg02 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq Rad (getdist "\nEnter radius: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) (repeat (+ NumSides 1) ; compute point (setq xpt (+ (nth 0 cpnt) (* Rad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* Rad (cos (dtr pang))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog03 () (graphscr) ; tower by polygon repeats ; taper (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg03 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq RadStart (getdist "\nEnter start radius: ")) (setq RadEnd (getdist "\nEnter end radius: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; radius inc (setq RadInc (/ (- RadEnd RadStart) NumLevels)) (setq Rad RadStart) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) (repeat (+ NumSides 1) ; compute point (setq xpt (+ (nth 0 cpnt) (* Rad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* Rad (cos (dtr pang))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc radius (setq Rad (+ Rad RadInc)) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog04 () (graphscr) ; tower by polygon repeats ; twist (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg04 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq RadStart (getdist "\nEnter start radius: ")) (setq RadEnd (getdist "\nEnter end radius: ")) (setq RotTotal (getreal "\nEnter total rotation angle: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; radius inc (setq RadInc (/ (- RadEnd RadStart) NumLevels)) (setq Rad RadStart) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 0.0) s ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) (repeat (+ NumSides 1) ; compute point (setq xpt (+ (nth 0 cpnt) (* Rad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* Rad (cos (dtr pang))))) ; rotate point (setq rxpt (- (* xpt (cos (dtr Rotang))) (* ypt (sin (dtr Rotang))))) (setq rypt (+ (* xpt (sin (dtr Rotang))) (* ypt (cos (dtr Rotang))))) (setq npnt (list rxpt rypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc radius (setq Rad (+ Rad RadInc)) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc rotation (setq Rotang (+ Rotang Rotinc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog05 () (graphscr) ; tower by polygon repeats ; offsets (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get tower parameters (princ "\nProg05 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq RadStart (getdist "\nEnter start radius: ")) (setq RadEnd (getdist "\nEnter end radius: ")) (setq Xoffset (getdist "\nEnter top X offset: ")) (setq Yoffset (getdist "\nEnter top Y offset: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; radius inc (setq RadInc (/ (- RadEnd RadStart) NumLevels)) (setq Rad RadStart) ; offset inc (setq XoffInc (/ Xoffset NumLevels)) (setq Xoff 0.0) (setq YoffInc (/ Yoffset NumLevels)) (setq Yoff 0.0) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) (repeat (+ NumSides 1) ; compute point (setq xpt (+ (+ (nth 0 cpnt) (* Rad (sin (dtr pang)))) Xoff)) (setq ypt (+ (+ (nth 1 cpnt) (* Rad (cos (dtr pang)))) Yoff)) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc radius (setq Rad (+ Rad RadInc)) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc offset (setq Xoff (+ Xoff XoffInc)) (setq Yoff (+ Yoff YoffInc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog06 () (graphscr) ; tower by polygon repeats ; elliptical form (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get tower parameters (princ "\nProg06 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq XRad (getdist "\nEnter X radius: ")) (setq YRad (getdist "\nEnter Y radius: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) (repeat (+ NumSides 1) ; compute point (setq xpt (+ (nth 0 cpnt) (* XRad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* YRad (cos (dtr pang))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog07 () (graphscr) ; tower by polygon repeats ; elliptical form (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get tower parameters (princ "\nProg07 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq XRadStart (getdist "\nEnter start X radius: ")) (setq XRadEnd (getdist "\nEnter end X radius: ")) (setq YRadStart (getdist "\nEnter start Y radius: ")) (setq YRadEnd (getdist "\nEnter end Y radius: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; radius inc (setq XRadInc (/ (- XRadEnd XRadStart) NumLevels)) (setq XRad XRadStart) ; radius inc (setq YRadInc (/ (- YRadEnd YRadStart) NumLevels)) (setq YRad YRadStart) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) (repeat (+ NumSides 1) ; compute point (setq xpt (+ (nth 0 cpnt) (* XRad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* YRad (cos (dtr pang))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc radius (setq XRad (+ XRad XRadInc)) (setq YRad (+ YRad YRadInc)) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog08 () (graphscr) ; tower by polygon repeats ; curve applied to offset (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get tower parameters (princ "\nProg08 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq Rad (getdist "\nEnter radius: ")) (setq RadOff (getdist "\nEnter radius offset: ")) (setq RadOffAng (getreal "\nEnter radius offset angle: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; offset ang (setq ranginc (/ RadOffAng Numlevels)) (setq rang 0.0) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) (repeat (+ NumSides 1) ; compute point (setq NewRad (+ Rad (* (sin (dtr rang)) RadOff))) (setq xpt (+ (nth 0 cpnt) (* NewRad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* NewRad (cos (dtr pang))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc offset angle (setq rang (+ rang ranginc)) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog09 () (graphscr) ; tower repeats ; curve on selective edges (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg09 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq Rad (getdist "\nEnter radius: ")) (setq RadOff (getdist "\nEnter radius offset: ")) (setq RadOffAng (getreal "\nEnter radius offset angle: ")) (setq ModPts (read (getstring "\nEnter list of points to modify: "))) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; offset ang (setq ranginc (/ RadOffAng Numlevels)) (setq rang 0.0) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) ; point counter (setq pcnt 1) (repeat (+ NumSides 1) ; compute point (setq NewRad Rad) ; check to modify point (if (> (length (member pcnt ModPts)) 0) (setq NewRad (+ Rad (* (sin (dtr rang)) RadOff))) ) (setq xpt (+ (nth 0 cpnt) (* NewRad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* NewRad (cos (dtr pang))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ; inc count (setq pcnt (+ pcnt 1)) ) ; inc offset angle (setq rang (+ rang ranginc)) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog10a () (graphscr) ; tower repeats ; Cardioid Curve for section ; x = 2 a cos t (1 + cos t) ; y = 2 a sin t (1 + cos t) (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg10a - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of curve sides: ")) (setq RadStart (getdist "\nEnter start radius: ")) (setq RadEnd (getdist "\nEnter radius end: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; radius inc (setq RadInc (/ (- RadEnd RadStart) NumLevels)) (setq Rad RadStart) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang 0.0) (repeat (+ NumSides 1) ; compute point (setq xpt (* 2 (* (/ Rad 4) (* (cos (dtr pang)) (+ 1 (cos (dtr pang))))))) (setq ypt (* 2 (* (/ Rad 4) (* (sin (dtr pang)) (+ 1 (cos (dtr pang))))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc radius (setq Rad (+ Rad RadInc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog10b () (graphscr) ; tower repeats ; Geometric Pedal B Curve for section ; r = a + (b * COS(angle)^2n) ; x = (r * radius) * COS(angle) ; y = (r * radius) * SIN(angle) (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg10b - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of curve sides: ")) (setq RadStart (getdist "\nEnter start radius: ")) (setq RadEnd (getdist "\nEnter radius end: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; radius inc (setq RadInc (/ (- RadEnd RadStart) NumLevels)) (setq Rad RadStart) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang 0.0) (repeat (+ NumSides 1) ; compute point (setq rval (+ 2.0 (* 1.0 (expt (cos (dtr pang)) (* 2 8.0))))) (setq xpt (* (* rval (/ Rad 4)) (cos (dtr pang)))) (setq ypt (* (* rval (/ Rad 4)) (sin (dtr pang)))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc radius (setq Rad (+ Rad RadInc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun xprog10c () (graphscr) ; tower repeats ; Hippopede curve for section ; x = (2 * COS t) * SQRT((major radius * minor radius) - (minor radius^2 * SIN t^2)) ; y = (2 * SIN t) * SQRT((major radius * minor radius) - (minor radius^2 * SIN t^2)) (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg10c - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of curve sides: ")) (setq XRadStart (getdist "\nEnter X radius: ")) (setq YRadStart (getreal "\nEnter Y radius start factor: ")) (setq YRadEnd (getreal "\nEnter Y radius end factor: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; radius inc (setq YRadInc (/ (- YRadEnd YRadStart) NumLevels)) (setq YRadFact YRadStart) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang 0.0) (repeat (+ NumSides 1) ; compute point (setq Xrad (/ XRadStart 2)) (setq YRad (* YRadFact XRad)) (setq xpt (* (* 2 (cos (dtr pang))) (sqrt (- (* XRad YRad) (* (expt YRad 2) (expt (sin (dtr pang)) 2)))))) (setq ypt (* (* 2 (sin (dtr pang))) (sqrt (- (* XRad YRad) (* (expt YRad 2) (expt (sin (dtr pang)) 2)))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc radius (setq YRadFact (+ YRadFact YRadInc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog10c () (graphscr) ; tower repeats ; Hippopede curve for section ; x = (2 * COS t) * SQRT((major radius * minor radius) - (minor radius^2 * SIN t^2)) ; y = (2 * SIN t) * SQRT((major radius * minor radius) - (minor radius^2 * SIN t^2)) ; with rotation (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg10c - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of curve sides: ")) (setq XRadStart (getdist "\nEnter X radius: ")) (setq YRadStart (getreal "\nEnter Y radius start factor: ")) (setq YRadEnd (getreal "\nEnter Y radius end factor: ")) (setq RotTotal (getreal "\nEnter total rotation angle: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 0.0) ; radius inc (setq YRadInc (/ (- YRadEnd YRadStart) NumLevels)) (setq YRadFact YRadStart) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang 0.0) (repeat (+ NumSides 1) ; compute point (setq Xrad (/ XRadStart 2)) (setq YRad (* YRadFact XRad)) (setq xpt (* (* 2 (cos (dtr pang))) (sqrt (- (* XRad YRad) (* (expt YRad 2) (expt (sin (dtr pang)) 2)))))) (setq ypt (* (* 2 (sin (dtr pang))) (sqrt (- (* XRad YRad) (* (expt YRad 2) (expt (sin (dtr pang)) 2)))))) ; rotate (setq rxpt (- (* xpt (cos (dtr Rotang))) (* ypt (sin (dtr Rotang))))) (setq rypt (+ (* xpt (sin (dtr Rotang))) (* ypt (cos (dtr Rotang))))) (setq npnt (list rxpt rypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc radius (setq YRadFact (+ YRadFact YRadInc)) ; inc rotation (setq Rotang (+ Rotang Rotinc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog10d () (graphscr) ; tower repeats ; curve for section ; r = (1.0 + ((e * (cos t * pedals))) / p ; x = (r * radius) * cos t ; y = (r * radius) * sin t (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg10d - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of curve sides: ")) (setq Rad (getdist "\nEnter radius: ")) (setq NumPedals (getint "\nEnter number of pedals: ")) (setq cfactStart (getreal "\nEnter curve factor start: ")) (setq cfactEnd (getreal "\nEnter curve factor end: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; radius inc (setq cfactInc (/ (- cfactEnd cfactStart) NumLevels)) (setq cfact cfactStart) ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang 0.0) (repeat (+ NumSides 1) ; compute point (setq r (+ 1.0 (* cfact (cos (* (dtr pang) NumPedals))))) (setq xpt (* (* r (* Rad 0.62)) (cos (dtr pang)))) (setq ypt (* (* r (* Rad 0.62)) (sin (dtr pang)))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc radius (setq cfact (+ cfact cfactInc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog11a () (graphscr) ; tower repeats ; partial polygon section (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get tower parameters (princ "\nProg11a - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq AngSides (getreal "\nEnter total angle for polygon: ")) (setq Rad (getdist "\nEnter radius: ")) (setq RotTotal (getreal "\nEnter total rotation angle: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ (+ NumSides 1) 2)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 3) (command npnt) ) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 0.0) ; create each level (repeat (+ NumLevels 1) ; first center pt (setq fpnt (list (nth 0 cpnt) (nth 1 cpnt) LevelElev)) (command fpnt) ; draw polygon (setq panginc (/ AngSides NumSides)) (setq pang (/ panginc 2.0)) (repeat (+ NumSides 1) ; compute point (setq xpt (+ (nth 0 cpnt) (* Rad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* Rad (cos (dtr pang))))) ; rotate (setq rxpt (- (* xpt (cos (dtr Rotang))) (* ypt (sin (dtr Rotang))))) (setq rypt (+ (* xpt (sin (dtr Rotang))) (* ypt (cos (dtr Rotang))))) (setq npnt (list rxpt rypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; back to first pt (command fpnt) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc rotation (setq Rotang (+ Rotang Rotinc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 3) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- (defun prog11b () (graphscr) ; tower repeats ; partial polygon section (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg11b - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq AngStart (getreal "\nEnter start angle for polygon: ")) (setq AngEnd (getreal "\nEnter end angle for polygon: ")) (setq Rad (getdist "\nEnter radius: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 3)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 3) (command npnt) ) ; polygon ang inc (setq AngInc (/ (- AngStart AngEnd) NumLevels)) (setq Polyang AngStart) ; create each level (repeat (+ NumLevels 1) ; first center pt (setq fpnt (list (nth 0 cpnt) (nth 1 cpnt) LevelElev)) (command fpnt) ; draw polygon (setq panginc (/ Polyang NumSides)) (setq pang 0.0) (repeat (+ NumSides 1) ; compute point (setq xpt (+ (nth 0 cpnt) (* Rad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* Rad (cos (dtr pang))))) (setq npnt (list xpt ypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) ; back to first pt (command fpnt) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc polygon ang (setq Polyang (- Polyang AngInc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 3) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog12 () (graphscr) ; tower repeats ; section from a list of points (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg12 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq BotSect (read (getstring "\nEnter bottom list of points: "))) (setq RotTotal (getreal "\nEnter total rotation angle: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 0.0) ; points (setq npts (length BotSect)) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) npts) ; add bottom (setq npnt cpnt) (repeat npts (command npnt) ) ; create each level (repeat (+ NumLevels 1) (setq npt 0) (repeat npts ; get point (setq xpt (* 12 (nth 0 (nth npt BotSect)))) (setq ypt (* 12 (nth 1 (nth npt BotSect)))) ; rotate (setq rxpt (- (* xpt (cos (dtr Rotang))) (* ypt (sin (dtr Rotang))))) (setq rypt (+ (* xpt (sin (dtr Rotang))) (* ypt (cos (dtr Rotang))))) (setq npnt (list rxpt rypt LevelElev)) ; add to mesh (command npnt) ; next pt (setq npt (+ npt 1)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) (setq nlevel (+ nlevel 1)) ; inc rotation (setq Rotang (+ Rotang Rotinc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat npts (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog13 () (graphscr) ; tower repeats ; morph from lists of points (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg13 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq BotSect (read (getstring "\nEnter bottom list of points: "))) (setq TopSect (read (getstring "\nEnter top list of points: "))) (setq RotTotal (getreal "\nEnter total rotation angle: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) ; points (setq npts (length BotSect)) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 0.0) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) npts) ; add bottom (setq npnt cpnt) (repeat npts (command npnt) ) ; create each level (setq nlevel 0) (repeat (+ NumLevels 1) (setq npt 0) (repeat npts ; get point (setq xpt (nth 0 (nth npt BotSect))) (setq ypt (nth 1 (nth npt BotSect))) ; compute inc (setq xinc (/ (- (nth 0 (nth npt TopSect)) (nth 0 (nth npt BotSect))) NumLevels)) (setq yinc (/ (- (nth 1 (nth npt TopSect)) (nth 1 (nth npt BotSect))) NumLevels)) ; add to pt (setq xpt (+ (* xpt 12) (* (* xinc 12) nlevel))) (setq ypt (+ (* ypt 12) (* (* yinc 12) nlevel))) ; rotate (setq rxpt (- (* xpt (cos (dtr Rotang))) (* ypt (sin (dtr Rotang))))) (setq rypt (+ (* xpt (sin (dtr Rotang))) (* ypt (cos (dtr Rotang))))) (setq npnt (list rxpt rypt LevelElev)) ; add to mesh (command npnt) ; next pt (setq npt (+ npt 1)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) (setq nlevel (+ nlevel 1)) ; inc rotation (setq Rotang (+ Rotang Rotinc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat npts (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ; -------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog14 () (graphscr) ; tower by polygon repeats ; twist ; with areas (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg14 - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq NumSides (getint "\nEnter number of polygon sides: ")) (setq RadStart (getdist "\nEnter start radius: ")) (setq RadEnd (getdist "\nEnter end radius: ")) (setq RotTotal (getreal "\nEnter total rotation angle: ")) ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set total area (setq TotalArea 0.0) ; set elev (setq LevelElev 0.0) ; radius inc (setq RadInc (/ (- RadEnd RadStart) NumLevels)) (setq Rad RadStart) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 0.0) s ; create each level (repeat (+ NumLevels 1) ; draw polygon (setq panginc (/ 360.0 NumSides)) (setq pang (/ panginc 2.0)) (command ".PLINE") (repeat (+ NumSides 1) ; compute point (setq xpt (+ (nth 0 cpnt) (* Rad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* Rad (cos (dtr pang))))) ; rotate point (setq rxpt (- (* xpt (cos (dtr Rotang))) (* ypt (sin (dtr Rotang))))) (setq rypt (+ (* xpt (sin (dtr Rotang))) (* ypt (cos (dtr Rotang))))) (setq npnt (list rxpt rypt LevelElev)) ; add to mesh (command npnt) ; inc ang (setq pang (+ pang panginc)) ) (command "c") ; get area (command ".AREA" "o" "last") ; acum area (setq FlrArea (/ (getvar "area") 144)) (setq TotalArea (+ TotalArea FlrArea)) ; convert to a region (command ".REGION" "last" "") ; inc radius (setq Rad (+ Rad RadInc)) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc rotation (setq Rotang (+ Rotang Rotinc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ "\nTotal Area: ") (princ (rtos TotalArea 2 0)) (princ " sqft") (princ) ) ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog15 (cpnt NumLevels LevelHeight XSide YSide / npnt LevelElev pnt1 pnt2 pnt3 pnt4) ; tower rectangular section ; by center and sides ; set sides (setq NumSides 4) ; set elev (setq LevelElev (nth 2 cpnt)) ; start mesh (command ".3DMESH" (+ (+ NumLevels 1) 2) (+ NumSides 1)) ; add bottom (setq npnt cpnt) (repeat (+ NumSides 1) (command npnt) ) ; create each level (repeat (+ NumLevels 1) ; compute rectangle points (setq pnt1 (list (- (nth 0 cpnt) (/ XSide 2.0)) (- (nth 1 cpnt) (/ YSide 2.0)) LevelElev)) (setq pnt2 (list (+ (nth 0 cpnt) (/ XSide 2.0)) (- (nth 1 cpnt) (/ YSide 2.0)) LevelElev)) (setq pnt3 (list (+ (nth 0 cpnt) (/ XSide 2.0)) (+ (nth 1 cpnt) (/ YSide 2.0)) LevelElev)) (setq pnt4 (list (- (nth 0 cpnt) (/ XSide 2.0)) (+ (nth 1 cpnt) (/ YSide 2.0)) LevelElev)) ; add to mesh (command pnt1 pnt2 pnt3 pnt4 pnt1) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 1) (command npnt) ) (princ) ) ;-------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun drwg15 () ; step back square tower (setvar "CMDECHO" 0) ; get tower parameters (setq TowerLayer "drwg15") ; clear layer (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".LAYER" "MAKE" TowerLayer "") (command ".LAYER" "SET" 0 "") (command ".LAYER" "OFF" "@*" "FREEZE" "@*" "") (command ".LAYER" "THAW" TowerLayer "ON" TowerLayer "SET" TowerLayer "") (command ".ERASE" "ALL" "") ; set elev (setq LevelElev 0.0) (setq cpnt (list 0.0 0.0 LevelElev)) ; abse tower (prog15 cpnt 30 (* 10 12) (* 100 12) (* 100 12)) ; first setback (setq LevelElev (+ LevelElev (* 30 (* 10 12)))) (setq cpnt (list (* 12.5 12) (* 12.5 12) LevelElev)) (prog15 cpnt 30 (* 10 12) (* 75 12) (* 75 12)) ; second setback (setq LevelElev (+ LevelElev (* 30 (* 10 12)))) (setq cpnt (list (* 25.0 12) (* 25.0 12) LevelElev)) (prog15 cpnt 30 (* 10 12) (* 50 12) (* 50 12)) (setvar "CMDECHO" 1) (command ".VIEW" "swiso") (command ".ZOOM" "e") (command ".HIDE") (princ) ) ;-------------------------------------------------------------------------- ;---------------------------------------------------------------------------- ;---------------------------------------------------------------------------- ; load solid modelling DLL (arxload "geom3d") ;----------------------------------------------------------------------------