; The Codewriting Workbook ; Creating Computational Architecture in AutoLISP ; by Robert J. Krawczyk ; Princeton Architectural Press, 2008 ; -------------------------------------------------------------------------- ; CH05A.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) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG01:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq numtimes (getint "\nEnter number of lines:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; loop to repeat lines (repeat numtimes ; compute endpoint (setq epnt (polar xpnt (dtr 90) linelen)) ; draw line (command ".LINE" xpnt epnt "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG02:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; loop to repeat lines (repeat numtimes ; compute endpoint (setq epnt (polar xpnt (dtr 90) linelen)) ; set extrude height (command ".ELEV" 0.0 zheight) ; draw line (command ".LINE" xpnt epnt "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog03 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG03:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ 360.0 (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq newlinelen (* linelen (sin (dtr ang)))) ; compute endpoint (setq epnt (polar xpnt (dtr 90) newlinelen)) ; set extrude height (command ".ELEV" 0.0 zheight) ; draw line (command ".LINE" xpnt epnt "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog04 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG04:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ 360.0 (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq newlinelen (* linelen (cos (dtr ang)))) ; compute endpoint (setq epnt (polar xpnt (dtr 90) newlinelen)) ; set extrude height (command ".ELEV" 0.0 zheight) ; draw line (command ".LINE" xpnt epnt "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog05 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG05:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ 360.0 (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq newlinelen (* linelen (abs (cos (dtr ang))))) ; compute endpoint (setq epnt (polar xpnt (dtr 90) newlinelen)) ; set extrude height (command ".ELEV" 0.0 zheight) ; draw line (command ".LINE" xpnt epnt "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog06 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG06:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ 360.0 (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt (polar xpnt (dtr 90) newlinelen)) ; set extrude height (command ".ELEV" 0.0 zheight) ; draw line (command ".LINE" xpnt epnt "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog07 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG07:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt (polar xpnt (dtr 90) newlinelen)) ; set extrude height (command ".ELEV" 0.0 zheight) ; draw line (command ".LINE" xpnt epnt "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog08 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG08:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt (polar xpnt (dtr 90) newlinelen)) ; compute height (setq linepart1 (* zheight linefact)) (setq linepart2 (* (* zheight (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzheight (+ linepart1 linepart2)) ; set extrude height (command ".ELEV" 0.0 newzheight) ; draw line (command ".LINE" xpnt epnt "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog09 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG09:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute height (setq linepart1 (* zheight linefact)) (setq linepart2 (* (* zheight (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzheight (+ linepart1 linepart2)) ; set extrude height (command ".ELEV" 0.0 newzheight) ; draw line (command ".LINE" xpnt epnt1 "") (command ".LINE" xpnt epnt2 "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog10 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG10:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute height (setq linepart1 (* zheight linefact)) (setq linepart2 (* (* zheight (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzheight (+ linepart1 linepart2)) ; set extrude height (command ".ELEV" 0.0 newzheight) ; draw line (command ".LINE" xpnt epnt1 "") (command ".LINE" xpnt epnt2 "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog11 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG11:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute height (setq linepart1 (* zheight linefact)) (setq linepart2 (* (* zheight (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzheight (+ linepart1 linepart2)) ; set extrude height (command ".ELEV" 0.0 newzheight) ; draw line (command ".LINE" xpnt epnt1 "") (command ".LINE" xpnt epnt2 "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog12 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG12:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute height (setq linepart1 (* zheight linefact)) (setq linepart2 (* (* zheight (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzheight (+ linepart1 linepart2)) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzheight))) (setq pnt3 (list (nth 0 xpnt) (nth 1 xpnt) (+ (nth 2 xpnt) newzheight))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzheight))) (setq pnt5 epnt1) ; draw 3DPOLY (command ".3DPOLY" pnt1 pnt2 pnt3 pnt4 pnt5 "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog13 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG13:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zheight (getdist spnt "\nEnter Height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zheight linefact)) (setq linepart2 (* (* zheight (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzheight (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zheight linefact)) (setq linepart2 (* (* zheight (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newmidzheight (+ linepart1 linepart2)) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzheight))) (setq pnt3 (list (nth 0 xpnt) (nth 1 xpnt) (+ (nth 2 xpnt) newmidzheight))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzheight))) (setq pnt5 epnt1) ; draw 3DPOLY (command ".3DPOLY" pnt1 pnt2 pnt3 pnt4 pnt5 "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog14 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG14:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzedge))) (setq pnt3 (list (nth 0 xpnt) (nth 1 xpnt) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzedge))) (setq pnt5 epnt1) ; draw 3DPOLY (command ".3DPOLY" pnt1 pnt2 pnt3 pnt4 pnt5 "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog15 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG15:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute frame points (setq pnt1 (list (nth 0 xpnt) (- (nth 1 xpnt) linelen) (nth 2 xpnt))) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzedge))) (setq pnt3 (list (nth 0 xpnt) (nth 1 xpnt) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzedge))) (setq pnt5 (list (nth 0 xpnt) (+ (nth 1 xpnt) linelen) (nth 2 xpnt))) ; draw 3DPOLY (command ".3DPOLY" pnt1 pnt2 pnt3 pnt4 pnt5 "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog15a () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG15a:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 xpnt) (- (nth 1 xpnt) linelen) (+ (nth 2 xpnt) newzedge))) (setq pnt3 (list (nth 0 xpnt) (nth 1 xpnt) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 xpnt) (+ (nth 1 xpnt) linelen) (+ (nth 2 xpnt) newzedge))) (setq pnt5 epnt1) ; draw 3DPOLY (command ".3DPOLY" pnt1 pnt2 pnt3 pnt4 pnt5 "") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog16 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG16:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; start 3DMESH (command ".3DMESH" numtimes "5") ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzedge))) (setq pnt3 (list (nth 0 xpnt) (nth 1 xpnt) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzedge))) (setq pnt5 epnt1) ; add points to 3DMESH (command pnt1 pnt2 pnt3 pnt4 pnt5) ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog17 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG17:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; start 3DMESH (command ".3DMESH" (+ numtimes 2) "6") ; frame counter (setq cnt 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzedge))) (setq pnt3 (list (nth 0 xpnt) (nth 1 xpnt) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzedge))) (setq pnt5 epnt1) ; inc frames (setq cnt (+ cnt 1)) ; check if before first frame (if (= cnt 1) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; add points to 3DMESH (command pnt1 pnt2 pnt3 pnt4 pnt5 pnt1) ; check if before first frame (if (= cnt numtimes) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog18 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG18:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq yoff (getdist spnt "\nEnter midpoint offset:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; start 3DMESH (command ".3DMESH" (+ numtimes 2) "6") ; frame counter (setq cnt 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute midpoint offset (setq newyoff (* yoff (sin (dtr ang)))) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzedge))) (setq pnt3 (list (nth 0 xpnt) (+ (nth 1 xpnt) newyoff) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzedge))) (setq pnt5 epnt1) ; inc frames (setq cnt (+ cnt 1)) ; check if before first frame (if (= cnt 1) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; add points to 3DMESH (command pnt1 pnt2 pnt3 pnt4 pnt5 pnt1) ; check if before first frame (if (= cnt numtimes) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun docurve () ; get center point and dimensions (prompt "\nDraw curve by entered expression") (setq pt0 (getpoint "\nPick start:")) (setq cexp (getstring "\nEnter curve expression:")) (setq sang (getint "\nEnter start angle:")) (setq eang (getint "\nEnter end angle:")) ; set Y and X dims (setq ymax 50.0) (setq xmax 200.0) ; draw axis lines (setq pt1 (list (+ (nth 0 pt0) xmax) (nth 1 pt0) 0)) (command ".LINE" pt0 pt1 "") (setq pt1 (list (nth 0 pt0) (+ (nth 1 pt0) ymax) 0)) (setq pt2 (list (+ (nth 0 pt0) xmax) (+ (nth 1 pt0) ymax) 0)) (command ".LINE" pt1 pt2 "") (setq pt1 (list (nth 0 pt0) (- (nth 1 pt0) ymax) 0)) (setq pt2 (list (+ (nth 0 pt0) xmax) (- (nth 1 pt0) ymax) 0)) (command ".LINE" pt1 pt2 "") (setq ytext (* (/ ymax 10.0) 0.8)) (setq pt1 (list (nth 0 pt0) (- (- (nth 1 pt0) ymax) ytext) 0)) (setq ytext (* (/ ymax 10.0) 0.5)) (setq stext (strcat cexp " from: " (itoa sang) " to: " (itoa eang))) (command ".TEXT" pt1 ytext "0.0" stext) (command ".ZOOM" "e") ; ang inc (setq anginc 1.0) (setq ang sang) ; start and X (setq xinc (/ xmax (- eang sang))) (setq xpt 0.0) ; start (command ".PLINE") (while (<= ang eang) ; compute height (setq ypt (* ymax (eval (read cexp)))) ; add point (command (list (+ (nth 0 pt0) xpt) (+ (nth 1 pt0) ypt) 0)) ; inc ang and x coord (setq ang (+ ang anginc)) (setq xpt (+ xpt xinc)) ) ; close (command "") (command ".ZOOM" "e" ".ZOOM" "0.9x") (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog18a () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG18a:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq yoff (getdist spnt "\nEnter midpoint offset:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; start 3DMESH (command ".3DMESH" (+ numtimes 2) "6") ; frame counter (setq cnt 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute midpoint offset (setq newyoff (* yoff (sin (dtr ang)))) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzedge))) (setq pnt3 (list (nth 0 xpnt) (+ (nth 1 xpnt) newyoff) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzedge))) (setq pnt5 epnt1) ; inc frames (setq cnt (+ cnt 1)) ; check if before first frame (if (= cnt 1) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; add points to 3DMESH (command pnt1 pnt2 pnt3 pnt4 pnt5 pnt1) ; check if before first frame (if (= cnt numtimes) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; design parameters (setq xdim (- (nth 0 cpnt) (nth 0 spnt))) (setq ydim (- (nth 1 cpnt) (nth 1 spnt))) (setq textpt (list (- (nth 0 spnt) 18) (+ (nth 1 spnt) ydim) 0.0)) (command ".TEXT" textpt 12 270 (strcat "PROG18" "/" (rtos xdim 4 2) " X " (rtos ydim 4 2) "/Edge Hght=" (rtos zedge 4 2) "/Mid Hght=" (rtos zmid 4 2) )) (setq textpt (list (- (nth 0 textpt) 18) (nth 1 textpt) 0.0)) (command ".TEXT" textpt 12 270 (strcat "/Lines=" (rtos numtimes 2 0) "/Line Factor=" (rtos linefact 2 2) "/Cycles=" (rtos numcycles 2 2) )) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- (defun prog19 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG19:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq yoff (getdist spnt "\nEnter midpoint offset:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; start 3DMESH (command ".3DMESH" (+ numtimes 2) "6") ; frame counter (setq cnt 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute midpoint offset (setq newyoff (* yoff (sin (dtr ang)))) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzedge))) (setq pnt3 (list (nth 0 xpnt) (+ (nth 1 xpnt) newyoff) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzedge))) (setq pnt5 epnt1) ; inc frames (setq cnt (+ cnt 1)) ; check if before first frame (if (= cnt 1) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; add points to 3DMESH (command pnt1 pnt2 pnt3 pnt4 pnt5 pnt1) ; check if before first frame (if (= cnt numtimes) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) ; rotate vertical (command ".ZOOM" "e") (command ".ROTATE3D" "all" "" "Y" "" "-90") (command ".ZOOM" "e") (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog20 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG20:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq yoff (getdist spnt "\nEnter midpoint offset:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) ; start 3DMESH (command ".3DMESH" (+ numtimes 2) "9") ; frame counter (setq cnt 0) ; loop to repeat lines (repeat numtimes ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr 90) newlinelen)) (setq epnt2 (polar xpnt (dtr 270) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute midpoint offset (setq newyoff (* yoff (sin (dtr ang)))) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzedge))) (setq pnt3 (list (nth 0 xpnt) (+ (nth 1 xpnt) newyoff) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzedge))) (setq pnt5 epnt1) (setq pnt6 (list (nth 0 pnt5) (nth 1 pnt5) (- newzedge))) (setq pnt7 (list (nth 0 pnt3) (nth 1 pnt3) (- newzmid))) (setq pnt8 (list (nth 0 pnt1) (nth 1 pnt1) (- newzedge))) ; inc frames (setq cnt (+ cnt 1)) ; check if before first frame (if (= cnt 1) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; add points to 3DMESH (command pnt1 pnt2 pnt3 pnt4 pnt5 pnt6 pnt7 pnt8 pnt1) ; check if before first frame (if (= cnt numtimes) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) ; rotate vertical (command ".ZOOM" "e") (command ".ROTATE3D" "all" "" "Y" "" "-90") (command ".ZOOM" "e") (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog21 () (graphscr) ; set extrude height (command ".ELEV" 0.0 0.0) ; get boundary points and parameters (prompt "\nPROG21:") (setq spnt (getpoint "\nPick start point:")) (setq cpnt (getcorner spnt "\nPick end point:")) (setq zedge (getdist spnt "\nEnter edge height:")) (setq zmid (getdist spnt "\nEnter midpoint height:")) (setq yoff (getdist spnt "\nEnter midpoint offset:")) (setq numtimes (getint "\nEnter number of lines:")) (setq linefact (getreal "\nEnter keep line factor:")) (setq numcycles (getreal "\nNumber of curve cycles:")) (setq clang (getreal "\Enter total angle for centerline:")) (setq cangoff (getdist "\nEnter centerline angle offset:")) ; compute line length, width of boundary (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across boundary (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq anginc (/ (* 360.0 numcycles) (- numtimes 1))) (setq canginc (/ clang (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; start ang (setq ang 0) (setq cang 0) ; start 3DMESH (command ".3DMESH" (+ numtimes 2) "6") ; frame counter (setq cnt 0) ; loop to repeat lines (repeat numtimes ; new centerline (setq clangoff (* (sin (dtr cang)) cangoff)) (setq xpnt (list (nth 0 xpnt) (+ (nth 1 spnt) clangoff) (nth 2 xpnt))) ; set direction (setq ldirang 90) (setq rdirang 270) (if (> cnt 0) (progn (setq dirang (rtd (angle lpnt xpnt))) (setq ldirang (+ dirang 90)) (setq rdirang (- dirang 90)) )) ; compute line length (setq linepart1 (* linelen linefact)) (setq linepart2 (* (* linelen (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newlinelen (+ linepart1 linepart2)) ; compute endpoint (setq epnt1 (polar xpnt (dtr ldirang) newlinelen)) (setq epnt2 (polar xpnt (dtr rdirang) newlinelen)) ; compute edge height (setq linepart1 (* zedge linefact)) (setq linepart2 (* (* zedge (- 1.0 linefact)) (abs (cos (dtr ang))))) (setq newzedge (+ linepart1 linepart2)) ; compute midpoint height (setq linepart1 (* zmid linefact)) (setq linepart2 (* (* zmid (- 1.0 linefact)) (abs (sin (dtr ang))))) (setq newzmid (+ linepart1 linepart2)) ; compute midpoint offset (setq newyoff (* yoff (sin (dtr ang)))) ; compute frame points (setq pnt1 epnt2) (setq pnt2 (list (nth 0 epnt2) (nth 1 epnt2) (+ (nth 2 epnt2) newzedge))) (setq pnt3 (list (nth 0 xpnt) (+ (nth 1 xpnt) newyoff) (+ (nth 2 xpnt) newzmid))) (setq pnt4 (list (nth 0 epnt1) (nth 1 epnt1) (+ (nth 2 epnt1) newzedge))) (setq pnt5 epnt1) ; inc frames (setq cnt (+ cnt 1)) ; check if before first frame (if (= cnt 1) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; add points to 3DMESH (command pnt1 pnt2 pnt3 pnt4 pnt5 pnt1) ; check if before first frame (if (= cnt numtimes) (progn ; add front face to mesh (command xpnt xpnt xpnt xpnt xpnt xpnt xpnt) )) ; same last center point (setq lpnt xpnt) ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (list xpt (nth 1 xpnt) (nth 2 xpnt))) ; inc ang (setq ang (+ ang anginc)) (setq cang (+ cang canginc)) ) ; set extrude height (command ".ELEV" 0.0 0.0) (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- ; prog91 - three part section cut, create dwg for cutting ; prog92 - 3D view of model ; -------------------------------------------------------------------------- (defun prog91 () ; laser cuts for model ; based on PROG14 ; laser cut sections with no base slots ; sections at 3/16" ; 16 x 24 laser bed (setvar "CMDECHO" 1) (graphscr) (command ".LAYER" "THAW" "*" "ON" "*" "") (c:vt) (command ".ZOOM" "e") (command ".ERASE" "ALL" "") (command ".LAYER" "MAKE" "2DTEXT" "MAKE" "2DCUT" "MAKE" "3DID" "MAKE" "LAYOUT" "") (command ".LAYER" "COLOR" "7" "*" "") (command ".LAYER" "COLOR" "1" "2DCUT" "") (command ".LAYER" "COLOR" "3" "2DTEXT" "") (command ".LAYER" "OFF" "2DCUT,2DTEXT" "FREEZE" "2DCUT,2DTEXT" "") (command ".LAYER" "SET" "0" "") ;board ;(setq bthick (/ 3.0 16.0)) ;(setq bwid 15) ;(setq blen 20) ; get boundary points and parameters (prompt "\nRepeat lines within a box") (setq spnt (list 0.0 0.0 0.0)) (setq scriptid (getstring "\nScript id:")) (setq modelid (getstring "\nModel id: ")) (setq modelid (substr (strcase modelid) 1 1)) (setq clen (getreal "\nLength (ft):")) (setq cwid (getreal "\nWidth (ft):")) (setq zedge (getreal "\nEdge height (ft):")) (setq zmid (getreal "\nMidpoint height (ft):")) (setq eblenfact (getreal "\nBottom edge length keep line factor:")) (setq eblsang (getreal "\nBottom edge length, start angle:")) (setq ebleang (getreal "\nBottom edge length, end angle:")) (setq eblenfunc (getstring "\nBottom edge length function:")) (setq etlenfact (getreal "\nTop edge length keep line factor:")) (setq etlsang (getreal "\nTop edge length, start angle:")) (setq etleang (getreal "\nTop edge length, end angle:")) (setq etlenfunc (getstring "\nTop edge length function:")) (setq ehgtfact (getreal "\nEdge height keep line factor:")) (setq ehsang (getreal "\nEdge height, start angle:")) (setq eheang (getreal "\nEdge height, end angle:")) (setq ehgtfunc (getstring "Edge height function:")) (setq mhgtfact (getreal "\nMidpoint height keep line factor:")) (setq mhsang (getreal "\nMidpoint height, start angle:")) (setq mheang (getreal "\nMidpoint height, end angle:")) (setq mhgtfunc (getstring "Midpoint height function:")) (setq zmidoff (getreal "\nMidpoint offset (ft):")) (setq mhoffsang (getreal "\nMidpoint offset, start angle:")) (setq mhoffeang (getreal "\nMidpoint offset, end angle:")) (setq mhgtofffunc (getstring "Midpoint offset function:")) (setq frad (getreal "\nFillet radius (in):")) (setq foff (getreal "\nFrame offset (in):")) (setq noff (getreal "\nNegative offset top and sides (in):")) (setq nboff (getreal "\nNegative offset bottom (in):")) (setq modellen (getreal "\nModel length (in):")) (setq bthick (getreal "\nBoard thickness (in):")) (setq bwid (getreal "\nBoard width (in):")) (setq blen (getreal "\nBoard length (in):")) ; model parms (setq numtimes (fix (/ modellen bthick))) ; model scale (setq mscale (/ modellen (* clen 12))) (setq mclen (* (* clen 12) mscale)) (setq mcwid (* (* cwid 12) mscale)) (setq cpnt (list mclen (/ mcwid 2.0) 0.0)) (setq mzedge (* (* zedge 12) mscale)) (setq mzmid (* (* zmid 12) mscale)) (setq mzmidoff (* (* zmidoff 12) mscale)) (setq mfrad (* frad mscale)) (setq mfoff (* foff mscale)) (setq mnoff (* noff mscale)) (setq mnboff (* nboff mscale)) ; compute line length, width of box (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across box (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq blanginc (/ (- ebleang eblsang) (- numtimes 1))) (setq tlanginc (/ (- etleang etlsang) (- numtimes 1))) (setq eanginc (/ (- eheang ehsang) (- numtimes 1))) (setq manginc (/ (- mheang mhsang) (- numtimes 1))) (setq oanginc (/ (- mhoffeang mhoffsang) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) ; set angle computations (if (= (strcase eblenfunc) "SIN") (defun blfuncang (xrad) (sin xrad)) (defun blfuncang (xrad) (cos xrad))) (if (= (strcase etlenfunc) "SIN") (defun tlfuncang (xrad) (sin xrad)) (defun tlfuncang (xrad) (cos xrad))) (if (= (strcase ehgtfunc) "SIN") (defun efuncang (xrad) (sin xrad)) (defun efuncang (xrad) (cos xrad))) (if (= (strcase mhgtfunc) "SIN") (defun mfuncang (xrad) (sin xrad)) (defun mfuncang (xrad) (cos xrad))) (if (= (strcase mhgtofffunc) "SIN") (defun ofuncang (xrad) (sin xrad)) (defun ofuncang (xrad) (cos xrad))) ; start ang (setq blang eblsang) (setq tlang etlsang) (setq eang ehsang) (setq mang mhsang) (setq oang mhoffsang) ; set extrude height (command ".ELEV" 0.0 0.0) ; loop to repeat lines (setq nsect 0) (repeat numtimes ; compute bottom endpoint (setq line1 (* linelen eblenfact)) (setq line2 (* (* (* linelen (- 1.0 eblenfact)) (abs (blfuncang (dtr blang)))))) (setq newlen (+ line1 line2)) (setq epnt1 (polar xpnt (dtr 90) newlen)) (setq epnt2 (polar xpnt (dtr 270) newlen)) ; compute top endpoint (setq line1 (* linelen etlenfact)) (setq line2 (* (* (* linelen (- 1.0 etlenfact)) (abs (tlfuncang (dtr tlang)))))) (setq newlen (+ line1 line2)) (setq epnt3 (polar xpnt (dtr 90) newlen)) (setq epnt4 (polar xpnt (dtr 270) newlen)) ; compute outside height (setq line1 (* mzedge ehgtfact)) (setq line2 (* (* (* mzedge (- 1.0 ehgtfact)) (abs (efuncang (dtr eang)))))) (setq newzedge (+ line1 line2)) (setq epnt3 (list (+ (nth 0 epnt3) newzedge) (nth 1 epnt3) )) (setq epnt4 (list (+ (nth 0 epnt4) newzedge) (nth 1 epnt4) )) ; compute midpoint offset (setq newzmidoff (* (* mzmidoff (ofuncang (dtr oang))))) (setq epnt5 (list (nth 0 xpnt) (+ (nth 1 xpnt) newzmidoff))) ; compute midpoint height (setq line1 (* mzmid mhgtfact)) (setq line2 (* (* (* mzmid (- 1.0 mhgtfact)) (abs (mfuncang (dtr mang)))))) (setq newzmid (+ line1 line2)) (setq epnt5 (list (+ (nth 0 epnt5) newzmid) (nth 1 epnt5) )) ; center slot (setq xpntc (list (nth 0 xpnt) (nth 1 xpnt) )) (setq epnt6 (list (nth 0 xpntc) (+ (nth 1 xpntc) (/ 1.0 4.0)) )) (setq epnt7 (list (+ (nth 0 xpntc) (/ 1.0 32.0)) (+ (nth 1 xpntc) (/ 1.0 4.0)) )) (setq epnt10 (list (+ (nth 0 xpntc) (/ 1.0 32.0)) (nth 1 xpntc) )) (setq epnt8 (list (+ (nth 0 xpntc) (/ 1.0 32.0)) (- (nth 1 xpntc) (/ 1.0 4.0)) )) (setq epnt9 (list (nth 0 xpntc) (- (nth 1 xpntc) (/ 1.0 4.0)) )) (setq nsect (+ nsect 1)) ; pline for 2D ;(command ".PLINE" epnt10 epnt7 epnt6 epnt1 epnt3 epnt5 epnt4 epnt2 epnt9 epnt8 "C") (command ".PLINE" epnt6 epnt1 epnt3 epnt5 epnt4 epnt2 epnt9 "C") (command ".ZOOM" "E" ".ZOOM" "0.6x") ; round corners (setq ss1 (ssget "_L")) (if (> mfrad 0.0) (progn (command ".FILLET" "R" mfrad) (command ".FILLET" "P" epnt1) )) ;(command ".ZOOM" "E" ".ZOOM" "0.6x") ; duplicate (if (> mfoff 0.0) (progn (setq opnt (list (- (nth 0 epnt6) mfoff) (nth 1 epnt6))) (command ".OFFSET" mfoff epnt6 opnt "") ; tab cut ;(command ".LINE" epnt6 epnt9 "") )) ; top tab cut (command ".PLINE" epnt6 epnt7 epnt10 epnt8 epnt9 "") ; bottom tab cut (if (> mfoff 0.0) (progn ;(setq epnt6 (list (- (nth 0 xpntc) mfoff) (+ (nth 1 xpntc) (/ 1.0 2.0)) )) ;(setq epnt9 (list (- (nth 0 xpntc) mfoff) (- (nth 1 xpntc) (/ 1.0 2.0)) )) ;(setq opnt (list (+ (- (nth 0 epnt7) mnboff) (/ 1.0 32.0)) (nth 1 epnt7))) ;(command ".COPY" epnt7 "" epnt7 opnt) ;(command ".LINE" epnt6 epnt9 "") (setq epnt6 (list (- (nth 0 xpntc) mfoff) (+ (nth 1 xpntc) (/ 1.0 4.0)) )) (setq epnt7 (list (+ (- (nth 0 xpntc) mfoff) (/ 1.0 32.0)) (+ (nth 1 xpntc) (/ 1.0 4.0)) )) (setq epnt10 (list (+ (- (nth 0 xpntc) mfoff) (/ 1.0 32.0)) (nth 1 xpntc) )) (setq epnt8 (list (+ (- (nth 0 xpntc) mfoff) (/ 1.0 32.0)) (- (nth 1 xpntc) (/ 1.0 4.0)) )) (setq epnt9 (list (- (nth 0 xpntc) mfoff) (- (nth 1 xpntc) (/ 1.0 4.0)) )) (command ".PLINE" epnt6 epnt7 epnt10 epnt8 epnt9 "") )) (command ".ZOOM" "E" ".ZOOM" "0.6x") ; negative frame (if (> mnoff 0.0) (progn (setq xpnt1 (list (- (nth 0 xpntc) (+ mfoff mnboff)) (+ (+ (nth 1 xpntc) (/ mcwid 2)) (* mnoff 2)) )) (setq xpnt2 (list (- (nth 0 xpntc) (+ mfoff mnboff)) (- (- (nth 1 xpntc) (/ mcwid 2)) (* mnoff 2)) )) (setq xpnt3 (list (+ (nth 0 xpnt1) (+ (max mzedge mzmid) (+ (* mnoff 3) mnboff))) (nth 1 xpnt1) )) (setq xpnt4 (list (+ (nth 0 xpnt2) (+ (max mzedge mzmid) (+ (* mnoff 3) mnboff))) (nth 1 xpnt2) )) (command ".PLINE" xpnt1 xpnt3 xpnt4 xpnt2 xpnt1 "") )) ; add sect number ; positive (command ".TEXT" (list (+ (nth 0 xpntc) (/ 1.0 16.0)) (nth 1 xpntc)) (/ 1.0 16.0) "-90" (strcat modelid "-" (itoa nsect))) (command ".CHPROP" "L" "" "LAYER" "2DTEXT" "") ; positive (if (> mfoff 0.0) (progn (command ".TEXT" (list (+ (- (nth 0 xpntc) mfoff) (/ 1.0 128.0)) (+ (nth 1 xpntc) (/ 3.0 4.0))) (/ 1.0 16.0) "-90" (strcat modelid "-" (itoa nsect))) (command ".CHPROP" "L" "" "LAYER" "2DTEXT" "") )) ; negative (if (> mnoff 0.0) (progn (command ".TEXT" (list (+ (nth 0 xpntc) (+ (max mzedge mzmid) (* mnoff 1))) (nth 1 xpntc)) (/ 1.0 16.0) "-90" (strcat modelid "-" (itoa nsect))) (command ".CHPROP" "L" "" "LAYER" "2DTEXT" "") )) (command ".ZOOM" "E" ".ZOOM" "0.6x") (command ".CHPROP" "ALL" "" "LAYER" "2DCUT" "") ; next location (setq xnext (+ (+ 0 (+ (max mzedge mzmid) (+ (* mnoff 3) mnboff))) (/ 1.0 8.0)) ) (setq ynext (+ (+ (/ mcwid 1) (* (+ mnoff mfoff) 2)) (/ 1.0 4.0))) (setq xpnt (list (+ (nth 0 xpnt) xnext) (nth 1 xpnt) )) (if (> (+ (nth 0 xpnt) xnext) (+ (nth 0 spnt) bwid)) (progn (setq xpnt (list (nth 0 spnt) (- (nth 1 xpnt) ynext))) )) ; inc ang (setq blang (+ blang blanginc)) (setq tlang (+ tlang tlanginc)) (setq eang (+ eang eanginc)) (setq mang (+ mang manginc)) (setq oang (+ oang oanginc)) ) ; layout 2D (command ".LAYER" "SET" "LAYOUT" "") (setq epnt1 (list (- (nth 0 spnt) 0.5) (+ (nth 1 cpnt) 0.75) 0.0)) (setq epnt2 (list (+ (nth 0 epnt1) bwid) (nth 1 epnt1) 0.0)) (setq epnt3 (list (+ (nth 0 epnt1) bwid) (- (nth 1 epnt1) blen) 0.0)) (setq epnt4 (list (- (nth 0 spnt) 0.5) (nth 1 epnt3) 0.0)) (command ".PLINE" epnt1 epnt2 epnt3 epnt4 epnt1 "") (command ".LAYER" "SET" "0" "") (command ".LAYER" "THAW" "*" "ON" "*" "") (command ".CHPROP" "ALL" "" "COLOR" "BYLAYER" "") (c:vt) ; cut length (setq minpt (getvar "EXTMIN")) (setq maxpt (getvar "EXTMAX")) (setq cutlen (fix (+ 0.5 (abs (- (nth 1 minpt) (nth 1 maxpt)))))) ; id text (setq epnt1 (list (- (nth 0 spnt) 2.0) (nth 1 epnt3) 0.0)) (command ".TEXT" epnt1 (/ 1.0 4.0) "90" (strcat scriptid "/" (rtos clen 2 2) "/" (rtos cwid 2 2 ) "/" (rtos zedge 2 2 ) "/" (rtos zmid 2 2 ) "/" (rtos modellen 2 2 ) "/" (itoa numtimes) "/" (rtos bwid 2 2) "x" (rtos cutlen 2 2) "/")) (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog92 () ; 3D view of model ; based on PROG14 ; laser cut sections with no base slots ; sections at 3/16" ; 16 x 24 laser bed (setvar "CMDECHO" 0) (graphscr) (command ".LAYER" "THAW" "*" "ON" "*" "") (c:vt) (command ".ZOOM" "e") (command ".ERASE" "ALL" "") (command ".LAYER" "MAKE" "3DSECT" "MAKE" "3DBASE" "MAKE" "2DTEXT" "MAKE" "2DCUT" "MAKE" "3DID" "MAKE" "LAYOUT" "") (command ".LAYER" "COLOR" "7" "*" "") (command ".LAYER" "COLOR" "1" "2DCUT" "") (command ".LAYER" "COLOR" "3" "2DTEXT" "") (command ".LAYER" "OFF" "3DSECT,3DBASE" "") ; board ;(setq bthick (/ 3.0 16.0)) ;(setq bwid 15) ;(setq blen 20) ; get boundary points and parameters (prompt "\nRepeat lines within a box") (setq spnt (list 0.0 0.0 0.0)) (setq scriptid (getstring "\nScript id:")) (setq modelid (getstring "\nModel id: ")) (setq modelid (substr (strcase modelid) 1 1)) (setq clen (getreal "\nLength (ft):")) (setq cwid (getreal "\nWidth (ft):")) (setq zedge (getreal "\nEdge height (ft):")) (setq zmid (getreal "\nMidpoint height (ft):")) (setq eblenfact (getreal "\nBottom edge length keep line factor:")) (setq eblsang (getreal "\nBottom edge length, start angle:")) (setq ebleang (getreal "\nBottom edge length, end angle:")) (setq eblenfunc (getstring "\nBottom edge length function:")) (setq etlenfact (getreal "\nTop edge length keep line factor:")) (setq etlsang (getreal "\nTop edge length, start angle:")) (setq etleang (getreal "\nTop edge length, end angle:")) (setq etlenfunc (getstring "\nTop edge length function:")) (setq ehgtfact (getreal "\nEdge height keep line factor:")) (setq ehsang (getreal "\nEdge height, start angle:")) (setq eheang (getreal "\nEdge height, end angle:")) (setq ehgtfunc (getstring "\nEdge height function:")) (setq mhgtfact (getreal "\nMidpoint height keep line factor:")) (setq mhsang (getreal "\nMidpoint height, start angle:")) (setq mheang (getreal "\nMidpoint height, end angle:")) (setq mhgtfunc (getstring "\nMidpoint height function:")) (setq zmidoff (getreal "\nMidpoint offset (ft):")) (setq mhoffsang (getreal "\nMidpoint offset, start angle:")) (setq mhoffeang (getreal "\nMidpoint offset, end angle:")) (setq mhgtofffunc (getstring "\nMidpoint offset function:")) (setq frad (getreal "\nFillet radius (in):")) (setq foff (getreal "\nFrame offset (in):")) (setq noff (getreal "\nNegative offset top and sides (in):")) (setq nboff (getreal "\nNegative offset bottom (in):")) (setq modellen (getreal "\nModel length (in):")) (setq bthick (getreal "\nBoard thickness (in):")) (setq bwid (getreal "\nBoard width (in):")) (setq blen (getreal "\nBoard length (in):")) ; model parms (setq numtimes (fix (/ modellen bthick))) ; model scale (setq mscale (/ modellen (* clen 12))) (setq mclen (* (* clen 12) mscale)) (setq mcwid (* (* cwid 12) mscale)) (setq cpnt (list mclen (/ mcwid 2.0) 0.0)) (setq mzedge (* (* zedge 12) mscale)) (setq mzmid (* (* zmid 12) mscale)) (setq mzmidoff (* (* zmidoff 12) mscale)) (setq mfrad (* frad mscale)) (setq mfoff (* foff mscale)) (setq mnoff (* noff mscale)) (setq mnboff (* nboff mscale)) ; compute line length, width of box (setq linelen (- (nth 1 cpnt) (nth 1 spnt))) ; compute increment across box (setq xinc (/ (- (nth 0 cpnt) (nth 0 spnt)) (- numtimes 1))) ; computer ang inc (setq blanginc (/ (- ebleang eblsang) (- numtimes 1))) (setq tlanginc (/ (- etleang etlsang) (- numtimes 1))) (setq eanginc (/ (- eheang ehsang) (- numtimes 1))) (setq manginc (/ (- mheang mhsang) (- numtimes 1))) (setq oanginc (/ (- mhoffeang mhoffsang) (- numtimes 1))) ; set first point and first x coord (setq xpnt spnt) (setq xpt (nth 0 spnt)) ; set angle computations (if (= (strcase eblenfunc) "SIN") (defun blfuncang (xrad) (sin xrad)) (defun blfuncang (xrad) (cos xrad))) (if (= (strcase etlenfunc) "SIN") (defun tlfuncang (xrad) (sin xrad)) (defun tlfuncang (xrad) (cos xrad))) (if (= (strcase ehgtfunc) "SIN") (defun efuncang (xrad) (sin xrad)) (defun efuncang (xrad) (cos xrad))) (if (= (strcase mhgtfunc) "SIN") (defun mfuncang (xrad) (sin xrad)) (defun mfuncang (xrad) (cos xrad))) (if (= (strcase mhgtofffunc) "SIN") (defun ofuncang (xrad) (sin xrad)) (defun ofuncang (xrad) (cos xrad))) ; start ang (setq blang eblsang) (setq tlang etlsang) (setq eang ehsang) (setq mang mhsang) (setq oang mhoffsang) ; set extrude height (command ".ELEV" 0.0 0.0) ; start pts for sections (setq sxcpnt (- (nth 0 spnt) 1.0)) (setq xcpnt sxcpnt) (setq ycpnt (- (nth 1 cpnt) (+ (* linelen 3.0) 1.1))) ; loop to repeat lines (setq nsect 0) (repeat numtimes ; compute bottom endpoint (setq line1 (* linelen eblenfact)) (setq line2 (* (* (* linelen (- 1.0 eblenfact)) (abs (blfuncang (dtr blang)))))) (setq newlen (+ line1 line2)) (setq epnt3 (polar xpnt (dtr 90) newlen)) (setq epnt4 (polar xpnt (dtr 270) newlen)) ; compute top endpoint (setq line1 (* linelen etlenfact)) (setq line2 (* (* (* linelen (- 1.0 etlenfact)) (abs (tlfuncang (dtr tlang)))))) (setq newlen (+ line1 line2)) (setq epnt1 (polar xpnt (dtr 90) newlen)) (setq epnt2 (polar xpnt (dtr 270) newlen)) ; compute outside height (setq line1 (* mzedge ehgtfact)) (setq line2 (* (* (* mzedge (- 1.0 ehgtfact)) (abs (efuncang (dtr eang)))))) (setq newzedge (+ line1 line2)) (setq epnt1 (list (nth 0 epnt1) (nth 1 epnt1) newzedge)) (setq epnt2 (list (nth 0 epnt2) (nth 1 epnt2) newzedge)) ; compute midpoint offset (setq newzmidoff (* (* mzmidoff (ofuncang (dtr oang))))) (setq mpnt (list (nth 0 xpnt) (+ (nth 1 xpnt) newzmidoff) 0.0)) ; compute midpoint height (setq line1 (* mzmid mhgtfact)) (setq line2 (* (* (* mzmid (- 1.0 mhgtfact)) (abs (mfuncang (dtr mang)))))) (setq newzmid (+ line1 line2)) (setq mpnt (list (nth 0 mpnt) (nth 1 mpnt) newzmid)) (setq nsect (+ nsect 1)) ; pline for 3D (command ".LAYER" "SET" "3DSECT" "") (command ".3DPOLY" epnt3 epnt1 mpnt epnt2 epnt4 epnt3 "") (command ".EXTRUDE" "LAST" "" bthick "" ) (command ".ZOOM" "E") ; inc x coord (setq xpt (+ xpt xinc)) (setq xpnt (cons xpt (cdr xpnt))) ; inc ang (setq blang (+ blang blanginc)) (setq tlang (+ tlang tlanginc)) (setq eang (+ eang eanginc)) (setq mang (+ mang manginc)) (setq oang (+ oang oanginc)) ) ; base 3D (setq epnt2 (list (- (nth 0 spnt) 1.0) (+ (nth 1 cpnt) 1.0) 0.0)) (setq epnt3 (list (+ (nth 0 cpnt) 1.0) (+ (nth 1 cpnt) 1.0) 0.0)) (setq epnt4 (list (+ (nth 0 cpnt) 1.0) (* (+ (nth 1 cpnt) 1.0) -1.0) 0.0)) (setq epnt5 (list (- (nth 0 spnt) 1.0) (* (+ (nth 1 cpnt) 1.0) -1.0) 0.0)) (command ".LAYER" "SET" "3DBASE" "") (command ".3DFACE" epnt2 epnt3 epnt4 epnt5 "") (command ".ZOOM" "e") ; id text (setq epnt1 (list (+ (nth 0 spnt) 0.5) (+ (nth 1 cpnt) 2.5) 0.0)) (command ".LAYER" "SET" "3DID" "") (command ".TEXT" epnt1 (/ 1.0 4.0) "0" (strcat scriptid "/" (rtos clen 2 2) "/" (rtos cwid 2 2 ) "/" (rtos zedge 2 2 ) "/" (rtos zmid 2 2 ) "/" (rtos modellen 2 2 ) "/" (itoa numtimes) "/" )) (command ".LAYER" "SET" "0" "") (command ".CHPROP" "ALL" "" "COLOR" "BYLAYER" "") (command ".LAYER" "ON" "3DSECT,3DBASE" "") (command ".LAYER" "OFF" "2D*,LAYOUT" "FREEZE" "2D*,LAYOUT" "") (c:vsw) (command ".HIDE") (princ) ) ;---------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun prog61 () (graphscr) ; tower repeats (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61 - 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) (princ) ) ;-------------------------------------------------------------------------- (defun prog61a () (graphscr) ; tower by polygon repeats ; add bottom and top (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61a - 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61b () (graphscr) ; tower by polygon repeats ; taper (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61b - 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61c () (graphscr) ; tower by polygon repeats ; twist (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61c - 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) ; 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 (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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61d () (graphscr) ; tower by polygon repeats ; taper (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61d - 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61e () (graphscr) ; tower by polygon repeats ; elliptical form (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61e - 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 YRad (getdist "\nEnter Y 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 XRadInc (/ (- XRadEnd XRadStart) NumLevels)) (setq XRad XRadStart) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 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) (* XRad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* YRad (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)) ) ; inc radius (setq XRad (+ XRad XRadInc)) ; 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61m () (graphscr) ; tower by polygon repeats ; elliptical form (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61e - 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: ")) (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 XRadInc (/ (- XRadEnd XRadStart) NumLevels)) (setq XRad XRadStart) (setq YRadInc (/ (- YRadEnd YRadStart) NumLevels)) (setq YRad YRadStart) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 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) (* XRad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* YRad (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)) ) ; inc radius (setq XRad (+ XRad XRadInc)) (setq YRad (+ YRad YRadInc)) ; 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61n () (graphscr) ; tower by polygon repeats ; elliptical form (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61e - 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: ")) (setq RotTotal (getreal "\nEnter total rotation angle: ")) (setq XRotOff (getdist "\nEnter X rotation offset: ")) (setq YRotOff (getdist "\nEnter Y rotation 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 XRadInc (/ (- XRadEnd XRadStart) NumLevels)) (setq XRad XRadStart) (setq YRadInc (/ (- YRadEnd YRadStart) NumLevels)) (setq YRad YRadStart) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 0.0) ; offset inc (setq XOffInc (/ XRotOff NumLevels)) (setq XOff 0.0) (setq YOffInc (/ YRotOff 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) (* XRad (sin (dtr pang))))) (setq ypt (+ (nth 1 cpnt) (* YRad (cos (dtr pang))))) ; rotate (setq rxpt (+ XOff (- (* xpt (cos (dtr Rotang))) (* ypt (sin (dtr Rotang)))))) (setq rypt (+ YOff (+ (* 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 XRad (+ XRad XRadInc)) (setq YRad (+ YRad YRadInc)) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) ; inc rotation (setq Rotang (+ Rotang Rotinc)) ; 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61f () (graphscr) ; tower by polygon repeats ; curve applied to offset (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61f - 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 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) ) ; offset ang (setq ranginc (/ RadOffAng Numlevels)) (setq rang 0.0) ; rotation inc (setq RotInc (/ RotTotal NumLevels)) (setq Rotang 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))))) ; 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 offset angle (setq rang (+ rang ranginc)) ; 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61g3 () (graphscr) ; tower repeats ; 4 sides ; curve on two opposite corners (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61g - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq Rad (getdist "\nEnter radius: ")) (setq RadOff (getdist "\nEnter radius offset: ")) (setq RadOffAng (getreal "\nEnter radius offset angle: ")) (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" "") ; number of sides (setq NumSides 3) ; 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) ; 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) Rotang)) ; compute points (setq pnt1 (polar cpnt (dtr pang) (+ Rad (* (sin (dtr rang)) RadOff)))) (setq pnt1 (list (nth 0 pnt1) (nth 1 pnt1) LevelElev)) (setq pang (+ pang panginc)) (setq pnt2 (polar cpnt (dtr pang) Rad)) (setq pnt2 (list (nth 0 pnt2) (nth 1 pnt2) LevelElev)) (setq pang (+ pang panginc)) (setq pnt3 (polar cpnt (dtr pang) Rad)) (setq pnt3 (list (nth 0 pnt3) (nth 1 pnt3) LevelElev)) ; add to mesh (command pnt1 pnt2 pnt3 pnt1) ; inc offset angle (setq rang (+ rang ranginc)) ; 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61g4 () (graphscr) ; tower repeats ; 4 sides ; curve on two opposite corners (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61g - Tower") (setq TowerLayer (getstring "\nEnter layer name: ")) (setq NumLevels (getint "\nEnter number of levels: ")) (setq LevelHeight (getdist "\nEnter level height: ")) (setq Rad (getdist "\nEnter radius: ")) (setq RadOff (getdist "\nEnter radius offset: ")) (setq RadOffAng (getreal "\nEnter radius offset angle: ")) (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" "") ; number of sides (setq NumSides 4) ; 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) ; 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) Rotang)) ; compute points (setq pnt1 (polar cpnt (dtr pang) (+ Rad (* (sin (dtr rang)) RadOff)))) (setq pnt1 (list (nth 0 pnt1) (nth 1 pnt1) LevelElev)) (setq pang (+ pang panginc)) (setq pnt2 (polar cpnt (dtr pang) Rad)) (setq pnt2 (list (nth 0 pnt2) (nth 1 pnt2) LevelElev)) (setq pang (+ pang panginc)) (setq pnt3 (polar cpnt (dtr pang) (+ Rad (* (sin (dtr rang)) RadOff)))) (setq pnt3 (list (nth 0 pnt3) (nth 1 pnt3) LevelElev)) (setq pang (+ pang panginc)) (setq pnt4 (polar cpnt (dtr pang) Rad)) (setq pnt4 (list (nth 0 pnt4) (nth 1 pnt4) LevelElev)) ; add to mesh (command pnt1 pnt2 pnt3 pnt4 pnt1) ; inc offset angle (setq rang (+ rang ranginc)) ; 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61h1 () (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 "\nProg61h1 - 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61h2 () (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 "\nProg61h2 - 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 prog61h2a () (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 "\nProg61h2 - 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61h3 () (graphscr) ; tower repeats ; Curve of convexities 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 "\nProg61h3 - 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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61i () (graphscr) ; tower repeats (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61i - 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 3)) ; 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) Rotang)) (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 rotation (setq Rotang (+ Rotang Rotinc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 3) (command npnt) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61j () (graphscr) ; tower repeats (setvar "CMDECHO" 0) ; center point (setq cpnt (list 0.0 0.0 0.0)) ; get curve parameters (princ "\nProg61j - 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) ) ; poyglon ag 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 ploygon ang (setq Polyang (- Polyang AngInc)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat (+ NumSides 3) (command npnt) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61k () (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 "\nProg61k - 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 (setq nlevel 0) (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) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ;-------------------------------------------------------------------------- (defun prog61l () (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 "\nProg61k - 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: "))) ; 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)) ; 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 npnt (list (+ (* xpt 12) (* (* xinc 12) nlevel)) (+ (* ypt 12) (* (* yinc 12) nlevel)) LevelElev)) ; add to mesh (command npnt) ; next pt (setq npt (+ npt 1)) ) ; inc elev (setq LevelElev (+ LevelElev LevelHeight)) (setq nlevel (+ nlevel 1)) ) ; add top (setq npnt (list (nth 0 cpnt) (nth 1 cpnt) (- LevelElev LevelHeight))) (repeat npts (command npnt) ) ; set view (c:vsw) ; hide (command ".HIDE") (setvar "CMDECHO" 1) (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- ;---------------------------------------------------------------------------- ;---------------------------------------------------------------------------- ; load solid modelling DLL (arxload "geom3d") ;----------------------------------------------------------------------------