; The Codewriting Workbook ; Creating Computational Architecture in AutoLISP ; by Robert J. Krawczyk ; Princeton Architectural Press, 2008 ; -------------------------------------------------------------------------- ; CH04.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)) ; Random number function, returns 0.0 to 1.0: (defun rn () (if (not sd) (setq sd (getvar "date"))) (setq md 65536 mx 25173 nc 13849 sd (rem (+ (* mx sd) nc) md)) (/ sd md) ) ;--------------------------------------------------------------------------- ; ZW - zoom window (defun c:zw () (command "zoom" "w") ) ; ZP - zoom previous (defun c:zp () (command "zoom" "p") ) ; ZE - zoom extents (defun c:ze () (command "zoom" "e" "zoom" ".9x") ) ; ZX - zoom .9x (defun c:zx () (command "zoom" ".9x") ) ;--------------------------------------------------------------------------- ; 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) ) ;--------------------------------------------------------------------------- ;-------------------------------------------------------------------------- (defun ex01 () (repeat 100000 ; get number (setq num (getint "\nEnter a number from -10 to 10: ")) ; check number (if (= num 0) (princ "\nNumber is equal to 0")) (if (> num 0) (princ "\nNumber is greater than 0")) (if (< num 0) (princ "\nNumber is less than 0")) (if (= (rem num 2) 0) (princ "\nNumber is even") (princ "\nNumber is odd") ) (if (>= num 0) (princ "\nNumber is Positive") (princ "\nNumber is Negative")) (if (/= num 5) (princ "\nNumber is not equal to 5")) (if (or (= num 5) (= num 6)) (princ "\nNumber is either 5 or 6")) (if (and (< num 5) (> num 0)) (princ "\nNumber is in the range 1 to 4")) (if (and (<= num 5) (>= num 0)) (princ "\nNumber is in the range 0 to 5")) (if (> num 6) (princ "\nNumber is greater than 6")) (if (= num 0) (exit)) ) (princ) ) ;-------------------------------------------------------------------------- (defun ex02 () (setq a 1) (setq n 10) (repeat n (princ a) (princ " ") (setq a (+ a 1)) ) (princ) ) ;-------------------------------------------------------------------------- (defun ex03 () (setq a 1) (while (< a 10) (princ a) (princ " ") (setq a (+ a 1)) ) (princ) ) ;-------------------------------------------------------------------------- (defun ex04 () (setq a 10) (while (> a 1) (princ a) (princ " ") (setq a (- a 1)) ) (princ) ) ;-------------------------------------------------------------------------- (defun ex05 () (setq doit 1) (setq a 0) (while (= doit 1) (princ a) (princ " ") (setq a (+ a 1)) (if (> a 10) (setq doit 0)) ) (princ) ) ;-------------------------------------------------------------------------- (defun ex06 () (setq doit 1) (setq a 1) (while (= doit 1) (princ "\n") (princ a) (setq a (+ a a)) (setq ans (getstring "\nMore?")) (if (= (strcase ans) "NO") (setq doit 0)) ) (princ) ) ;-------------------------------------------------------------------------- (defun ex07 () (setq xside 1) (while (< xside 10) (setq yside 1) (while (< yside 10) (princ "\n") (princ xside) (princ " x ") (princ yside) (setq yside (+ yside 1)) ) (setq xside (+ xside 1)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog01 () (graphscr) ; get center point and dimensions (prompt "\nDraw nested rectangles, by center") (setq pnt0 (getpoint "\nPick center:")) (setq xside (getdist "\nEnter length:")) (setq yside (getdist "\nEnter width:")) (setq numrects (getint "\nEnter number of rectangles:")) ; compute outside rectangle corners (setq pnt1 (list (- (nth 0 pnt0) (/ xside 2)) (- (nth 1 pnt0) (/ yside 2)) (nth 2 pnt0))) (setq pnt2 (list (+ (nth 0 pnt0) (/ xside 2)) (- (nth 1 pnt0) (/ yside 2)) (nth 2 pnt0))) (setq pnt3 (list (+ (nth 0 pnt0) (/ xside 2)) (+ (nth 1 pnt0) (/ yside 2)) (nth 2 pnt0))) (setq pnt4 (list (- (nth 0 pnt0) (/ xside 2)) (+ (nth 1 pnt0) (/ yside 2)) (nth 2 pnt0))) (repeat numrects ; draw rectangle (command ".PLINE" pnt1 pnt2 pnt3 pnt4 pnt1 "") ; compute midpoints (setq ang (angle pnt1 pnt2)) (setq dist (distance pnt1 pnt2)) (setq pnt5 (polar pnt1 ang (/ dist 2))) (setq ang (angle pnt2 pnt3)) (setq dist (distance pnt2 pnt3)) (setq pnt6 (polar pnt2 ang (/ dist 2))) (setq ang (angle pnt3 pnt4)) (setq dist (distance pnt3 pnt4)) (setq pnt7 (polar pnt3 ang (/ dist 2))) (setq ang (angle pnt4 pnt1)) (setq dist (distance pnt4 pnt1)) (setq pnt8 (polar pnt4 ang (/ dist 2))) ; reset points (setq pnt1 pnt5) (setq pnt2 pnt6) (setq pnt3 pnt7) (setq pnt4 pnt8) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog01x () (graphscr) ; get center point and dimensions (prompt "\nDraw nested rectangles, by center") (setq pnt0 (getpoint "\nPick center:")) (setq xside (getdist "\nEnter length:")) (setq yside (getdist "\nEnter width:")) (setq numrects (getint "\nEnter number of rectangles:")) ; compute outside rectangle corners (setq pnt1 (list (- (nth 0 pnt0) (/ xside 2)) (- (nth 1 pnt0) (/ yside 2)) 0.0)) (setq pnt2 (list (+ (nth 0 pnt0) (/ xside 2)) (- (nth 1 pnt0) (/ yside 2)) 0.0)) (setq pnt3 (list (+ (nth 0 pnt0) (/ xside 2)) (+ (nth 1 pnt0) (/ yside 2)) 0.0)) (setq pnt4 (list (- (nth 0 pnt0) (/ xside 2)) (+ (nth 1 pnt0) (/ yside 2)) 0.0)) (repeat numrects ; draw rectangle (command ".PLINE" pnt1 pnt2 pnt3 pnt4 pnt1 "") ; compute midpoints (setq pnt5 (list (+ (nth 0 pnt1) (/ (- (nth 0 pnt2) (nth 0 pnt1)) 2)) (+ (nth 1 pnt1) (/ (- (nth 1 pnt2) (nth 1 pnt1)) 2)) (nth 2 pnt1))) (setq pnt6 (list (+ (nth 0 pnt2) (/ (- (nth 0 pnt3) (nth 0 pnt2)) 2)) (+ (nth 1 pnt2) (/ (- (nth 1 pnt3) (nth 1 pnt2)) 2)) (nth 2 pnt2))) (setq pnt7 (list (+ (nth 0 pnt3) (/ (- (nth 0 pnt4) (nth 0 pnt3)) 2)) (+ (nth 1 pnt3) (/ (- (nth 1 pnt4) (nth 1 pnt3)) 2)) (nth 2 pnt3))) (setq pnt8 (list (+ (nth 0 pnt4) (/ (- (nth 0 pnt1) (nth 0 pnt4)) 2)) (+ (nth 1 pnt4) (/ (- (nth 1 pnt1) (nth 1 pnt4)) 2)) (nth 2 pnt4))) ; reset points (setq pnt1 pnt5) (setq pnt2 pnt6) (setq pnt3 pnt7) (setq pnt4 pnt8) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog01a () (graphscr) ; get four corner points (prompt "\nDraw nested rectangles, by four points") (setq pnt1 (getpoint "\nPick 1st corner:")) (setq pnt2 (getpoint pnt1 "\nPick 2nd corner:")) (setq pnt3 (getpoint pnt2 "\nPick 3rd corner:")) (setq pnt4 (getpoint pnt3 "\nPick 4th corner:")) (setq numrects (getint "\nEnter number of rectangles:")) (repeat numrects ; draw rectangle (command ".PLINE" pnt1 pnt2 pnt3 pnt4 pnt1 "") ; compute midpoints (setq savepnt1 pnt1) (setq ang (angle pnt1 pnt2)) (setq dist (distance pnt1 pnt2)) (setq pnt1 (polar pnt1 ang (/ dist 2))) (setq ang (angle pnt2 pnt3)) (setq dist (distance pnt2 pnt3)) (setq pnt2 (polar pnt2 ang (/ dist 2))) (setq ang (angle pnt3 pnt4)) (setq dist (distance pnt3 pnt4)) (setq pnt3 (polar pnt3 ang (/ dist 2))) (setq ang (angle pnt4 savepnt1)) (setq dist (distance pnt4 savepnt1)) (setq pnt4 (polar pnt4 ang (/ dist 2))) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02 () (graphscr) ; get center point and dimensions (prompt "\nDraw radial spiral") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute angle and line length increments (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines)) ; initial angle and line length (setq angline 0) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) ; draw line (command ".LINE" pnt0 pnt1 "") ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02a () (graphscr) ; get center point and dimensions (prompt "\nDraw radial spiral") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute angle and line length increments (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines )) ; initial angle is anginc (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) ; draw line (command ".LINE" pnt0 pnt1 "") ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02b () (graphscr) ; get center point and dimensions (prompt "\nDraw radial spiral, inc/dec") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) ; set the radius inc for half the lines (setq radinc (/ crad (/ numlines 2))) (setq angline anginc) (setq radline radinc) ; line counter (setq lsegs 0) ; draw circle (command ".CIRCLE" pnt0 crad) (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) ; draw line (command ".LINE" pnt0 pnt1 "") ; inc line count (setq lsegs (+ lsegs 1)) ; decrease inc at half point (if (= lsegs (/ numlines 2)) (setq radinc (* radinc -1.0))) ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02c () (graphscr) ; get center point and dimensions (prompt "\nDraw radial spiral, inc/dec twice") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) ; set the radius inc for 1/4 the lines (setq radinc (/ crad (fix (/ numlines 4)))) (setq angline anginc) (setq radline radinc) ; line counter (setq lsegs 0) ; draw circle (command ".CIRCLE" pnt0 crad) (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) ; draw line (command ".LINE" pnt0 pnt1 "") ; inc line count (setq lsegs (+ lsegs 1)) ; flip inc at 1/4 point (if (= (rem lsegs (fix (/ numlines 4))) 0) (setq radinc (* radinc -1.0))) ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02d () (graphscr) ; get center point and dimensions (prompt "\nDraw radial spiral") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines)) (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) ; first point (setq pnt1 pnt0) (repeat numlines ; compute second point (setq pnt2 (polar pnt0 (dtr angline) radline)) ; draw line (command ".LINE" pnt1 pnt2 "") ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ; make the last point first (setq pnt1 pnt2) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02e () (graphscr) ; get center point and dimensions (prompt "\nDraw radial spiral") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines)) (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) ; start the polyline (command ".PLINE" pnt0) (repeat numlines ; compute second point (setq pnt2 (polar pnt0 (dtr angline) radline)) ; add point (command pnt2) ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) ; close polyline (command "") (princ) ) ; -------------------------------------------------------------------------- (defun prog02f () (graphscr) ; get center point and dimensions (prompt "\nDraw the inverse of the radial spiral") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines )) (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) (setq pnt2 (polar pnt0 (dtr angline) crad)) ; draw line (command ".LINE" pnt1 pnt2 "") ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02g () (graphscr) ; get center point and dimensions (prompt "\nDraw inverse radial spiral") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines )) (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) (setq pnt2 (polar pnt0 (dtr angline) (+ radline crad))) ; draw line (command ".LINE" pnt1 pnt2 "") ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02h () (graphscr) ; get center point and dimensions (prompt "\nDraw inverse radial spiral, 3D lines") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines )) (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) (setq pnt2 (polar pnt0 (dtr angline) (+ radline crad))) ; set Z elev (setq pnt1 (list (nth 0 pnt1) (nth 1 pnt1) (/ radline 2))) (setq pnt2 (list (nth 0 pnt2) (nth 1 pnt2) (/ radline 2))) ; draw line (command ".LINE" pnt1 pnt2 "") ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02i () (graphscr) ; get center point and dimensions (prompt "\nDraw inverse radial spiral, 3D mesh ramp") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines )) (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) ; start mesh (command ".3DMESH" numlines "2") (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) (setq pnt2 (polar pnt0 (dtr angline) (+ radline crad))) ; set Z elev (setq pnt1 (list (nth 0 pnt1) (nth 1 pnt1) (/ radline 2))) (setq pnt2 (list (nth 0 pnt2) (nth 1 pnt2) (/ radline 2))) ; send points to mesh (command pnt1 pnt2) ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02j () (graphscr) ; get center point and dimensions (prompt "\nDraw inverse radial spiral, 3D mesh steps") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines )) (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) ; start mesh (command ".3DMESH" (* numlines 2) "2") (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) (setq pnt2 (polar pnt0 (dtr angline) (+ radline crad))) ; set Z elev (setq pnt1 (list (nth 0 pnt1) (nth 1 pnt1) (/ radline 2))) (setq pnt2 (list (nth 0 pnt2) (nth 1 pnt2) (/ radline 2))) (command pnt1 pnt2) ; compute next endpoint (setq pnt3 (polar pnt0 (dtr (+ angline anginc)) (+ radline radinc))) (setq pnt4 (polar pnt0 (dtr (+ angline anginc)) (+ (+ radline radinc) crad))) ; set Z elev (setq pnt3 (list (nth 0 pnt3) (nth 1 pnt3) (/ radline 2))) (setq pnt4 (list (nth 0 pnt4) (nth 1 pnt4) (/ radline 2))) ; send points to mesh (command pnt3 pnt4) ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02k () (graphscr) ; get center point and dimensions (prompt "\nDraw inverse radial spiral, 3D steps") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines )) (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) (repeat numlines ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) (setq pnt2 (polar pnt0 (dtr angline) (+ radline crad))) ; set Z elev (setq pnt1 (list (nth 0 pnt1) (nth 1 pnt1) (/ radline 2))) (setq pnt2 (list (nth 0 pnt2) (nth 1 pnt2) (/ radline 2))) ; compute next endpoint (setq pnt3 (polar pnt0 (dtr (+ angline anginc)) (+ radline radinc))) (setq pnt4 (polar pnt0 (dtr (+ angline anginc)) (+ (+ radline radinc) crad))) ; set Z elev (setq pnt3 (list (nth 0 pnt3) (nth 1 pnt3) (/ radline 2))) (setq pnt4 (list (nth 0 pnt4) (nth 1 pnt4) (/ radline 2))) ; make polyline (command ".PLINE" pnt1 pnt2 pnt4 pnt3 "c") ; extrude step (command ".EXTRUDE" "last" "" (/ radinc 2)) ; versions prior to 2007 use ;(command ".EXTRUDE" "last" "" (/ radinc 2) "0") ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02l () (graphscr) ; get center point and dimensions (prompt "\nDraw inverse radial spiral, 3D steps") (setq pnt0 (getpoint "\nPick center:")) (setq crad (getdist pnt0 "\nEnter radius:")) (setq numlines (getint "\nEnter number of lines:")) ; compute inc (setq anginc (/ 360.0 numlines)) (setq radinc (/ crad numlines )) (setq angline anginc) (setq radline radinc) ; draw circle (command ".CIRCLE" pnt0 crad) (repeat (* numlines 2) ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) radline)) (setq pnt2 (polar pnt0 (dtr angline) (+ radline crad))) ; set Z elev (setq pnt1 (list (nth 0 pnt1) (nth 1 pnt1) (/ radline 2))) (setq pnt2 (list (nth 0 pnt2) (nth 1 pnt2) (/ radline 2))) ; compute next endpoint (setq pnt3 (polar pnt0 (dtr (+ angline anginc)) (+ radline radinc))) (setq pnt4 (polar pnt0 (dtr (+ angline anginc)) (+ (+ radline radinc) crad))) ; set Z elev (setq pnt3 (list (nth 0 pnt3) (nth 1 pnt3) (/ radline 2))) (setq pnt4 (list (nth 0 pnt4) (nth 1 pnt4) (/ radline 2))) ; make polyline (command ".PLINE" pnt1 pnt2 pnt4 pnt3 "c") ; extrude step (command ".EXTRUDE" "last" "" (/ radinc 2)) ; versions prior to 2007 use ;(command ".EXTRUDE" "last" "" (/ radinc 2) "0") ; inc ang and length (setq angline (+ angline anginc)) (setq radline (+ radline radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog02m () (graphscr) ; get center point and dimensions (prompt "\nDraw a helix, 3D steps") (setq pnt0 (getpoint "\nPick center:")) (setq icrad (getdist pnt0 "\nEnter inside radius:")) (setq ocrad (getdist pnt0 "\nEnter outside radius:")) (setq numsegs (getint "\nEnter number of segments per turn:")) (setq numturns (getint "\nEnter number of turns:")) (setq zoff (getdist "\nEnter Z incremental height:")) ; compute inc (setq anginc (/ 360.0 numsegs)) (setq angline anginc) ; start Z (setq zpt 0.0) (repeat (* numsegs numturns) ; compute endpoint (setq pnt1 (polar pnt0 (dtr angline) icrad)) (setq pnt2 (polar pnt0 (dtr angline) ocrad)) ; set Z elev (setq pnt1 (list (nth 0 pnt1) (nth 1 pnt1) zpt)) (setq pnt2 (list (nth 0 pnt2) (nth 1 pnt2) zpt)) ; compute next endpoint (setq pnt3 (polar pnt0 (dtr (+ angline anginc)) icrad)) (setq pnt4 (polar pnt0 (dtr (+ angline anginc)) ocrad)) ; set Z elev (setq pnt3 (list (nth 0 pnt3) (nth 1 pnt3) zpt)) (setq pnt4 (list (nth 0 pnt4) (nth 1 pnt4) zpt)) ; make polyline (command ".PLINE" pnt1 pnt2 pnt4 pnt3 "c") ; extrude step (command ".EXTRUDE" "last" "" zoff) ; versions prior to 2007 use ;(command ".EXTRUDE" "last" "" zoff "0") ; inc ang and Z point (setq angline (+ angline anginc)) (setq zpt (+ zpt zoff)) ) (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog03 () (graphscr) ; get start and end point (prompt "\nDraw a linear series of circles") (setq pnt1 (getpoint "\nPick start center:")) (setq pnt2 (getpoint pnt1 "\nPick end center:")) (setq crad (getdist pnt1 "\nEnter circle radius:")) (setq numrepeat (getint "\nEnter number of repeats:")) ; compute inc (setq xdist (- (nth 0 pnt2) (nth 0 pnt1))) (setq xinc (/ xdist (- numrepeat 1))) ; draw line between start/end (command ".LINE" pnt1 pnt2 "") ; start (setq pntc pnt1) (repeat numrepeat ; draw circle (command ".CIRCLE" pntc crad) ; inc X (setq pntc (list (+ (nth 0 pntc) xinc) (nth 1 pntc) (nth 2 pntc))) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog03a () (graphscr) ; get start and end point (prompt "\nDraw a linear series of increasing circles") (setq pnt1 (getpoint "\nPick start center:")) (setq pnt2 (getpoint pnt1 "\nPick end center:")) (setq scrad (getdist pnt1 "\nEnter start circle radius:")) (setq ecrad (getdist pnt1 "\nEnter end circle radius:")) (setq numrepeat (getint "\nEnter number of repeats:")) ; compute inc (setq xdist (- (nth 0 pnt2) (nth 0 pnt1))) (setq xinc (/ xdist (- numrepeat 1))) (setq xrad (- ecrad scrad)) (setq radinc (/ xrad (- numrepeat 1))) ; draw line between start/end (command ".LINE" pnt1 pnt2 "") ; start (setq pntc pnt1) (setq crad scrad) (repeat numrepeat ; draw circle (command ".CIRCLE" pntc crad) ; inc X (setq pntc (list (+ (nth 0 pntc) xinc) (nth 1 pntc) (nth 2 pntc))) ; inc radius (setq crad (+ crad radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog03b () (graphscr) ; get start and end point (prompt "\nDraw a linear series of increasing/decreasing circles") (setq pnt1 (getpoint "\nPick start center:")) (setq pnt2 (getpoint pnt1 "\nPick end center:")) (setq scrad (getdist pnt1 "\nEnter start circle radius:")) (setq ecrad (getdist pnt1 "\nEnter end circle radius:")) (setq numrepeat (getint "\nEnter number of repeats:")) ; compute inc (setq xdist (- (nth 0 pnt2) (nth 0 pnt1))) (setq xinc (/ xdist (- numrepeat 1))) (setq xrad (- ecrad scrad)) ; compute mid number of repeats (setq midrepeat (fix (+ (/ numrepeat 2.0) 0.5))) (setq radinc (/ xrad (- midrepeat 1))) ; draw line between start/end (command ".LINE" pnt1 pnt2 "") ; start (setq pntc pnt1) (setq crad scrad) ; object counter (setq ncnt 0) (repeat numrepeat ; draw circle (command ".CIRCLE" pntc crad) ; inc objs drawn (setq ncnt (+ ncnt 1)) ; inc X (setq pntc (list (+ (nth 0 pntc) xinc) (nth 1 pntc) (nth 2 pntc))) ; check number of cicrles drawn (if (= ncnt midrepeat) (setq radinc (* radinc -1))) ; inc radius (setq crad (+ crad radinc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog03c () (graphscr) ; get start and end point (prompt "\nDraw a linear series of increasing/decresing circles") (setq pnt1 (getpoint "\nPick start center:")) (setq pnt2 (getpoint pnt1 "\nPick end center:")) (setq scrad (getdist pnt1 "\nEnter start circle radius:")) (setq ecrad (getdist pnt1 "\nEnter end circle radius:")) (setq numrepeat (getint "\nEnter number of repeats:")) ; compute inc (setq xdist (- (nth 0 pnt2) (nth 0 pnt1))) (setq xinc (/ xdist (- numrepeat 1))) (setq xrad (- ecrad scrad)) ; compute mid number of repeats (setq midrepeat (fix (+ (/ numrepeat 2.0) 0.5))) (setq radinc (/ xrad (- midrepeat 1))) ; draw line between start/end (command ".LINE" pnt1 pnt2 "") ; start (setq pntc pnt1) (setq crad scrad) ; object counter (setq ncnt 0) (repeat numrepeat ; draw circle (command ".CIRCLE" pntc crad) ; inc objs drawn (setq ncnt (+ ncnt 1)) ; inc X (setq pntc (list (+ (nth 0 pntc) xinc) (nth 1 pntc) (nth 2 pntc))) ; check number of objs drawn (if (= ncnt midrepeat) (setq radinc (* radinc -1))) ; check for odd/even number of repeats ; inc radius (if (= (rem numrepeat 2) 1) (setq crad (+ crad radinc))) (if (and (= (rem numrepeat 2) 0) (/= ncnt midrepeat)) (setq crad (+ crad radinc))) ) (princ) ) ; -------------------------------------------------------------------------- (defun dorectcen (pnt0 xside yside / pnt1 pnt2 pnt3 pnt4) ; compute points (setq pnt1 (list (- (nth 0 pnt0) (/ xside 2)) (- (nth 1 pnt0) (/ yside 2)) (nth 2 pnt0))) (setq pnt2 (list (+ (nth 0 pnt0) (/ xside 2)) (- (nth 1 pnt0) (/ yside 2)) (nth 2 pnt0))) (setq pnt3 (list (+ (nth 0 pnt0) (/ xside 2)) (+ (nth 1 pnt0) (/ yside 2)) (nth 2 pnt0))) (setq pnt4 (list (- (nth 0 pnt0) (/ xside 2)) (+ (nth 1 pnt0) (/ yside 2)) (nth 2 pnt0))) ; draw rectangle (command ".PLINE" pnt1 pnt2 pnt3 pnt4 pnt1 "") (princ) ) ; -------------------------------------------------------------------------- (defun prog03d () (graphscr) ; get start and end point (prompt "\nDraw a linear series of increasing/decresing rectangles") (setq pnt1 (getpoint "\nPick start center:")) (setq pnt2 (getpoint pnt1 "\nPick end center:")) (setq slen (getdist pnt1 "\nEnter start rectangle length:")) (setq elen (getdist pnt1 "\nEnter end rectangle length:")) (setq swid (getdist pnt1 "\nEnter start rectangle width:")) (setq ewid (getdist pnt1 "\nEnter end rectangle width:")) (setq numrepeat (getint "\nEnter number of repeats:")) ; compute inc (setq xdist (- (nth 0 pnt2) (nth 0 pnt1))) (setq xinc (/ xdist (- numrepeat 1))) ; compute mid number of repeats (setq midrepeat (fix (+ (/ numrepeat 2.0) 0.5))) ; compute length and width inc (setq linc (/ (- elen slen) (- midrepeat 1))) (setq winc (/ (- ewid swid) (- midrepeat 1))) ; draw line between start/end (command ".LINE" pnt1 pnt2 "") ; start (setq pntc pnt1) (setq rlen slen) (setq rwid swid) ; object counter (setq ncnt 0) (repeat numrepeat ; draw rectangle (dorectcen pntc rlen rwid) ; inc objs drawn (setq ncnt (+ ncnt 1)) ; inc X (setq pntc (list (+ (nth 0 pntc) xinc) (nth 1 pntc) (nth 2 pntc))) ; check number of objs drawn (if (= ncnt midrepeat) (progn (setq linc (* linc -1)) (setq winc (* winc -1)) )) ; check for odd/even number of repeats ; inc dims (if (= (rem numrepeat 2) 1) (progn (setq rlen (+ rlen linc)) (setq rwid (+ rwid winc)) )) (if (and (= (rem numrepeat 2) 0) (/= ncnt midrepeat)) (progn (setq rlen (+ rlen linc)) (setq rwid (+ rwid winc)) )) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog03e () (graphscr) ; get start and end point (prompt "\nDraw a linear series of increasing/decresing 3D rectangles") (setq pnt1 (getpoint "\nPick start center:")) (setq pnt2 (getpoint pnt1 "\nPick end center:")) (setq slen (getdist pnt1 "\nEnter start rectangle length:")) (setq elen (getdist pnt1 "\nEnter end rectangle length:")) (setq swid (getdist pnt1 "\nEnter start rectangle width:")) (setq ewid (getdist pnt1 "\nEnter end rectangle width:")) (setq shgt (getdist pnt1 "\nEnter start rectangle height:")) (setq ehgt (getdist pnt1 "\nEnter end rectangle height:")) (setq numrepeat (getint "\nEnter number of repeats:")) ; compute inc (setq xdist (- (nth 0 pnt2) (nth 0 pnt1))) (setq xinc (/ xdist (- numrepeat 1))) ; compute mid number of repeats (setq midrepeat (fix (+ (/ numrepeat 2.0) 0.5))) ; compute length, width, height inc (setq linc (/ (- elen slen) (- midrepeat 1))) (setq winc (/ (- ewid swid) (- midrepeat 1))) (setq hinc (/ (- ehgt shgt) (- midrepeat 1))) ; draw line between start/end (command ".LINE" pnt1 pnt2 "") ; start (setq pntc pnt1) (setq rlen slen) (setq rwid swid) (setq rhgt shgt) ; object counter (setq ncnt 0) ; start an empty selection list (setq objs (ssadd)) (repeat numrepeat ; draw rectangle (dorectcen pntc rlen rwid) ; extrude (command ".EXTRUDE" "last" "" rhgt) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc objs drawn (setq ncnt (+ ncnt 1)) ; inc X (setq pntc (list (+ (nth 0 pntc) xinc) (nth 1 pntc) (nth 2 pntc))) ; check number of objs drawn (if (= ncnt midrepeat) (progn (setq linc (* linc -1)) (setq winc (* winc -1)) (setq hinc (* hinc -1)) )) ; check for odd/even number of repeats ; inc dims (if (= (rem numrepeat 2) 1) (progn (setq rlen (+ rlen linc)) (setq rwid (+ rwid winc)) (setq rhgt (+ rhgt hinc)) )) (if (and (= (rem numrepeat 2) 0) (/= ncnt midrepeat)) (progn (setq rlen (+ rlen linc)) (setq rwid (+ rwid winc)) (setq rhgt (+ rhgt hinc)) )) ) ; union objs (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- (defun prog03f () (graphscr) ; get start and end point (prompt "\nDraw a linear series of increasing/decresing 3D rectangles") (setq pnt1 (getpoint "\nPick start center:")) (setq pnt2 (getpoint pnt1 "\nPick end center:")) (setq slen (getdist pnt1 "\nEnter start rectangle length:")) (setq elen (getdist pnt1 "\nEnter end rectangle length:")) (setq swid (getdist pnt1 "\nEnter start rectangle width:")) (setq ewid (getdist pnt1 "\nEnter end rectangle width:")) (setq shgt (getdist pnt1 "\nEnter start rectangle height:")) (setq ehgt (getdist pnt1 "\nEnter end rectangle height:")) (setq sang (rtd (getorient "\nEnter start rotation angle:"))) (setq eang (rtd (getorient "\nEnter end rotation angle:"))) (setq numrepeat (getint "\nEnter number of repeats:")) ; compute inc (setq xdist (- (nth 0 pnt2) (nth 0 pnt1))) (setq xinc (/ xdist (- numrepeat 1))) ; compute mid number of repeats (setq midrepeat (fix (+ (/ numrepeat 2.0) 0.5))) ; compute length, width, height, angle inc (setq linc (/ (- elen slen) (- midrepeat 1))) (setq winc (/ (- ewid swid) (- midrepeat 1))) (setq hinc (/ (- ehgt shgt) (- midrepeat 1))) (setq ainc (/ (- eang sang) (- midrepeat 1))) ; draw line between start/end (command ".LINE" pnt1 pnt2 "") ; start (setq pntc pnt1) (setq rlen slen) (setq rwid swid) (setq rhgt shgt) (setq rang sang) ; object counter (setq ncnt 0) ; start an empty selection list (setq objs (ssadd)) (repeat numrepeat ; draw rectangle (dorectcen pntc rlen rwid) ; rotate (command ".ROTATE" "last" "" pntc rang) ; extrude (command ".EXTRUDE" "last" "" rhgt) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc objs drawn (setq ncnt (+ ncnt 1)) ; inc X (setq pntc (list (+ (nth 0 pntc) xinc) (nth 1 pntc) (nth 2 pntc))) ; check number of objs drawn (if (= ncnt midrepeat) (progn (setq linc (* linc -1)) (setq winc (* winc -1)) (setq hinc (* hinc -1)) ;(setq ainc (* ainc -1)) (setq rang (* rang -1)) )) ; check for odd/even number of repeats ; inc dims (if (= (rem numrepeat 2) 1) (progn (setq rlen (+ rlen linc)) (setq rwid (+ rwid winc)) (setq rhgt (+ rhgt hinc)) (setq rang (+ rang ainc)) )) (if (and (= (rem numrepeat 2) 0) (/= ncnt midrepeat)) (progn (setq rlen (+ rlen linc)) (setq rwid (+ rwid winc)) (setq rhgt (+ rhgt hinc)) (setq rang (+ rang ainc)) )) ) ; union objs (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- (defun sign (x) (if (< x 0.0) (- 0 1) (+ 0 1))) ; -------------------------------------------------------------------------- (defun prog03fx () (graphscr) ; get start and end point (prompt "\nDraw a linear series of increasing/decresing 3D rectangles") (setq pnt1 (getpoint "\nPick start center:")) (setq pnt2 (getpoint pnt1 "\nPick end center:")) (setq slen (getdist pnt1 "\nEnter start rectangle length:")) (setq elen (getdist pnt1 "\nEnter end rectangle length:")) (setq swid (getdist pnt1 "\nEnter start rectangle width:")) (setq ewid (getdist pnt1 "\nEnter end rectangle width:")) (setq shgt (getdist pnt1 "\nEnter start rectangle height:")) (setq ehgt (getdist pnt1 "\nEnter end rectangle height:")) (setq sang (rtd (getorient "\nEnter start rotation angle:"))) (setq eang (rtd (getorient "\nEnter end rotation angle:"))) (setq numrepeat (getint "\nEnter number of repeats:")) ; compute inc (setq xdist (- (nth 0 pnt2) (nth 0 pnt1))) (setq xinc (/ xdist (- numrepeat 1))) ; compute mid number of repeats (setq midrepeat (fix (+ (/ numrepeat 2.0) 0.5))) ; compute length, width, height, angle inc (setq linc (/ (- elen slen) (- midrepeat 1))) (setq winc (/ (- ewid swid) (- midrepeat 1))) (setq hinc (/ (- ehgt shgt) (- midrepeat 1))) (setq ainc (/ (- eang sang) (- midrepeat 1))) ; draw line between start/end (command ".LINE" pnt1 pnt2 "") ; start (setq pntc pnt1) (setq rlen slen) (setq rwid swid) (setq rhgt shgt) (setq rang sang) ; object counter (setq ncnt 0) ; start an empty selection list (setq objs (ssadd)) (repeat numrepeat ; draw rectangle (dorectcen pntc rlen rwid) ; rotate (command ".ROTATE" "last" "" pntc (* (sign ainc) rang)) (princ "\n")(princ rang) ; extrude (command ".EXTRUDE" "last" "" rhgt) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc objs drawn (setq ncnt (+ ncnt 1)) ; inc X (setq pntc (list (+ (nth 0 pntc) xinc) (nth 1 pntc) (nth 2 pntc))) ; check number of objs drawn (if (= ncnt midrepeat) (progn (setq linc (* linc -1)) (setq winc (* winc -1)) (setq hinc (* hinc -1)) (setq ainc (* ainc -1)) )) ; check for odd/even number of repeats ; inc dims (if (= (rem numrepeat 2) 1) (progn (setq rlen (+ rlen linc)) (setq rwid (+ rwid winc)) (setq rhgt (+ rhgt hinc)) (setq rang (+ rang ainc)) )) (if (and (= (rem numrepeat 2) 0) (/= ncnt midrepeat)) (progn (setq rlen (+ rlen linc)) (setq rwid (+ rwid winc)) (setq rhgt (+ rhgt hinc)) (setq rang (+ rang ainc)) )) ) ; union objs (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- (defun prog03g () (graphscr) ; get start and end point (prompt "\nDraw a column of rotated sqaures") (setq pnt1 (getpoint "\nPick start center:")) (setq chgt (getdist pnt1 "\nEnter column height:")) (setq sdim (getdist pnt1 "\nEnter square size:")) (setq numrepeat (getint "\nEnter number of squares:")) (setq trot (rtd (getorient "\nEnter total rotation:"))) ; compute inc (setq zinc (/ chgt (- numrepeat 1))) (setq ainc (/ trot (- numrepeat 1))) ; start (setq pntc pnt1) (setq tang 0.0) ; start selection list (setq objs (ssadd)) (repeat numrepeat ; draw rectangle (dorectcen pntc sdim sdim) (command ".ZOOM" "e") ; rotate (command ".ROTATE" "last" "" pntc tang) ; extrude (command ".EXTRUDE" "last" "" zinc) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc Z (setq pntc (list (nth 0 pntc) (nth 1 pntc) (+ (nth 2 pntc) zinc))) ; inc angle (setq tang (+ tang ainc)) ) ; union column (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- (defun prog03h () (graphscr) ; get start and end point (prompt "\nDraw a column of ellipses") (setq pnt1 (getpoint "\nPick start center:")) (setq chgt (getdist pnt1 "\nEnter column height:")) (setq sxrad (getdist pnt1 "\nEnter ellipse start X radius:")) (setq exrad (getdist pnt1 "\nEnter ellipse end X radius:")) (setq syrad (getdist pnt1 "\nEnter ellipse start Y radius:")) (setq eyrad (getdist pnt1 "\nEnter ellipse end Y radius:")) (setq numrepeat (getint "\nEnter number of ellipses:")) ; compute inc (setq zinc (/ chgt (- numrepeat 1))) (setq xinc (/ (- exrad sxrad) (- numrepeat 1))) (setq yinc (/ (- eyrad syrad) (- numrepeat 1))) ; start (setq pntc pnt1) (setq xrad sxrad) (setq yrad syrad) ; start selection list (setq objs (ssadd)) (repeat numrepeat ; draw ellipse (setq xpt (list (+ (nth 0 pntc) xrad) (nth 1 pntc) (nth 2 pntc))) (setq ypt (list (nth 0 pntc) (+ (nth 1 pntc) yrad) (nth 2 pntc))) (command ".ELLIPSE" "c" pntc xpt ypt) (command ".ZOOM" "e") ; extrude (command ".EXTRUDE" "last" "" zinc) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc Z (setq pntc (list (nth 0 pntc) (nth 1 pntc) (+ (nth 2 pntc) zinc))) ; inc dims (setq xrad (+ xrad xinc)) (setq yrad (+ yrad yinc)) ) ; union column (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun dotrefoil (pnt0 crad / pnt1 pnt2 pnt3 obj1) (graphscr) ; first circle (setq pnt1 (polar pnt0 (dtr 90) crad)) (command ".CIRCLE" pnt1 crad) ; make region (command ".REGION" "last" "" ) ; place into selection list (setq obj1 (ssadd (entlast))) ; second circle (setq pnt2 (polar pnt0 (dtr 210) crad)) (command ".CIRCLE" pnt2 crad) ; make region (command ".REGION" "last" "" ) ; place into selection list (setq obj1 (ssadd (entlast) obj1)) ; third circle (setq pnt3 (polar pnt0 (dtr 330) crad)) (command ".CIRCLE" pnt3 crad) ; make region (command ".REGION" "last" "" ) ; place into selection list (setq obj1 (ssadd (entlast) obj1)) ; union are three (command ".UNION" obj1 "") (princ) ) ; -------------------------------------------------------------------------- (defun prog03gx () (graphscr) ; get start and end point (prompt "\nDraw a column of rotated trefoils") (setq pnt1 (getpoint "\nPick start center:")) (setq chgt (getdist pnt1 "\nEnter column height:")) (setq trad (getdist pnt1 "\nEnter trefoil radius:")) (setq numrepeat (getint "\nEnter number of trefoils:")) (setq trot (rtd (getorient "\nEnter total rotation:"))) ; compute inc (setq zinc (/ chgt (- numrepeat 1))) (setq ainc (/ trot (- numrepeat 1))) ; start (setq pntc pnt1) (setq tang 0.0) ; start selection list (setq objs (ssadd)) (repeat numrepeat ; draw trefoil (dotrefoil pntc trad) (command ".ZOOM" "e") ; rotate (command ".ROTATE" "last" "" pntc tang) ; extrude (command ".EXTRUDE" "last" "" zinc) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc Z (setq pntc (list (nth 0 pntc) (nth 1 pntc) (+ (nth 2 pntc) zinc))) ; inc angle (setq tang (+ tang ainc)) ) ; union all trefoils (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog04 () (graphscr) ; get center point and dimensions (prompt "\nDraw array of circles") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq crad (getdist pnt0 "\nEnter circle radius:")) (setq shgt (getdist pnt0 "\nEnter start height:")) (setq ehgt (getdist pnt0 "\nEnter end height:")) ; compute inc (setq zinc (/ (- ehgt shgt) (- ytimes 1))) ; start (setq ypt (nth 1 pnt0)) (setq zhgt shgt) ; start selection list (setq objs (ssadd)) (repeat ytimes (setq xpt (nth 0 pnt0)) (repeat xtimes ; array location (setq pntc (list xpt ypt (nth 2 pnt0))) ; draw circle (command ".CIRCLE" pntc crad) (command ".ZOOM" "e") (command ".EXTRUDE" "last" "" zhgt) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc X (setq xpt (+ xpt xoff)) ) ; inc Y (setq ypt (+ ypt yoff)) ; inc height (setq zhgt (+ zhgt zinc)) ) ; union objs (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- (defun prog04a () (graphscr) ; get center point and dimensions (prompt "\nDraw array of circles, height to center") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq crad (getdist pnt0 "\nEnter circle radius:")) (setq shgt (getdist pnt0 "\nEnter start height:")) (setq ehgt (getdist pnt0 "\nEnter end height:")) ; compute center (setq cpt (list (+ (nth 0 pnt0) (/ (* xoff (- xtimes 1)) 2)) (+ (nth 1 pnt0) (/ (* yoff (- ytimes 1)) 2)) (nth 2 pnt0))) ; start (setq ypt (nth 1 pnt0)) ; start selection list (setq objs (ssadd)) (repeat ytimes (setq xpt (nth 0 pnt0)) (repeat xtimes ; array location (setq pntc (list xpt ypt (nth 2 pnt0))) ; distance to center (setq cdist (distance pntc cpt)) ; compute height (setq zprct (- 1.0 (/ cdist (distance pnt0 cpt)))) (setq zhgt (+ shgt (* zprct (- ehgt shgt)))) ; draw circle (command ".CIRCLE" pntc crad) (command ".ZOOM" "e") (command ".EXTRUDE" "last" "" zhgt) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc X (setq xpt (+ xpt xoff)) ) ; inc Y (setq ypt (+ ypt yoff)) ) ; union objs (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- (defun prog04ax () (graphscr) ; get center point and dimensions (prompt "\nDraw array of circles, height to center") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq crad (getdist pnt0 "\nEnter circle radius:")) (setq shgt (getdist pnt0 "\nEnter start height:")) (setq ehgt (getdist pnt0 "\nEnter end height:")) ; compute center (setq cpt (list (+ (nth 0 pnt0) (/ (* xoff (- xtimes 1)) 2)) (+ (nth 1 pnt0) (/ (* yoff (- ytimes 1)) 2)) (nth 2 pnt0))) ; start (setq ypt (nth 1 pnt0)) ; start selection list (setq objs (ssadd)) (repeat ytimes (setq xpt (nth 0 pnt0)) (repeat xtimes ; array location (setq pntc (list xpt ypt (nth 2 pnt0))) ; distance to center (setq cdist (distance pntc cpt)) ; compute height (setq zprct (/ cdist (distance pnt0 cpt))) (setq zhgt (+ shgt (* zprct (- ehgt shgt)))) ; draw circle (command ".CIRCLE" pntc crad) (command ".ZOOM" "e") (command ".EXTRUDE" "last" "" zhgt) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc X (setq xpt (+ xpt xoff)) ) ; inc Y (setq ypt (+ ypt yoff)) ) ; union objs (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- (defun docring (pnt0 crad cthk / obj1 obj2) ; requires center, outside radius, and thicknes ; outside circle (command ".CIRCLE" pnt0 crad) ; make region (command ".REGION" "last" "" ) ; place into selection list (setq obj1 (ssadd (entlast))) ; inside circle (command ".CIRCLE" pnt0 (- crad cthk)) ; make region (command ".REGION" "last" "" ) ; place into a second selection list (setq obj2 (ssadd (entlast))) ; subtract inside from outside (command ".SUBTRACT" obj1 "" obj2 "") (princ) ) ; -------------------------------------------------------------------------- (defun prog04b () (graphscr) ; get center point and dimensions (prompt "\nDraw array of rings, radius to vertical center") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq scrad (getdist pnt0 "\nEnter start ring radius:")) (setq ecrad (getdist pnt0 "\nEnter end ring radius:")) (setq rthk (getdist pnt0 "\nEnter ring thickness:")) ; compute center (setq cpt (list (+ (nth 0 pnt0) (/ (* xoff (- xtimes 1)) 2)) (+ (nth 1 pnt0) (/ (* yoff (- ytimes 1)) 2)) (nth 2 pnt0))) ; start (setq ypt (nth 1 pnt0)) ; start selection list (setq objs (ssadd)) (repeat ytimes (setq xpt (nth 0 pnt0)) (repeat xtimes ; array location (setq pntc (list xpt ypt (nth 2 pnt0))) ; X distance to center (setq xdist (abs (- (nth 0 pntc) (nth 0 cpt)))) ; compute height (setq xprct (- 1.0 (/ xdist (abs (- (nth 0 pnt0) (nth 0 cpt)))))) (setq xrad (+ scrad (* xprct (- ecrad scrad)))) ; draw ring (docring pntc xrad rthk) (command ".ZOOM" "e") ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc X (setq xpt (+ xpt xoff)) ) ; inc Y (setq ypt (+ ypt yoff)) ) ; union objs (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- (defun prog04c () (graphscr) ; get center point and dimensions (prompt "\nDraw array of rings, radius to vertical center") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq scrad (getdist pnt0 "\nEnter start ring radius:")) (setq ecrad (getdist pnt0 "\nEnter end ring radius:")) (setq rthk (getdist pnt0 "\nEnter ring thickness:")) (setq shgt (getdist pnt0 "\nEnter start height:")) (setq ehgt (getdist pnt0 "\nEnter end height:")) ; compute center (setq cpt (list (+ (nth 0 pnt0) (/ (* xoff (- xtimes 1)) 2)) (+ (nth 1 pnt0) (/ (* yoff (- ytimes 1)) 2)) (nth 2 pnt0))) ; start (setq ypt (nth 1 pnt0)) ; start selection list (setq objs (ssadd)) (repeat ytimes (setq xpt (nth 0 pnt0)) (repeat xtimes ; array location (setq pntc (list xpt ypt (nth 2 pnt0))) ; X distance to center (setq xdist (abs (- (nth 0 pntc) (nth 0 cpt)))) ; compute height (setq xprct (/ xdist (abs (- (nth 0 pnt0) (nth 0 cpt))))) (setq xrad (+ scrad (* xprct (- ecrad scrad)))) (setq zhgt (+ shgt (* xprct (- ehgt shgt)))) ; draw ring (docring pntc xrad rthk) (command ".ZOOM" "e") (command ".EXTRUDE" "last" "" zhgt) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc X (setq xpt (+ xpt xoff)) ) ; inc Y (setq ypt (+ ypt yoff)) ) ; union objs (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- (defun prog04d () (graphscr) ; get center point and dimensions (prompt "\nDraw mesh, height to center") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq shgt (getdist pnt0 "\nEnter start height:")) (setq ehgt (getdist pnt0 "\nEnter end height:")) ; compute center (setq cpt (list (+ (nth 0 pnt0) (/ (* xoff (- xtimes 1)) 2)) (+ (nth 1 pnt0) (/ (* yoff (- ytimes 1)) 2)) (nth 2 pnt0))) ; start (setq ypt (nth 1 pnt0)) ; start mesh (command ".3DMESH" ytimes xtimes) (repeat ytimes (setq xpt (nth 0 pnt0)) (repeat xtimes ; array location (setq pntc (list xpt ypt (nth 2 pnt0))) ; distance to center (setq cdist (distance pntc cpt)) ; compute height (setq zprct (- 1.0 (/ cdist (distance pnt0 cpt)))) (setq zhgt (+ shgt (* zprct (- ehgt shgt)))) ; add Z value (setq pntc (list (nth 0 pntc) (nth 1 pntc) zhgt)) ; add point to mesh (command pntc) ; inc X (setq xpt (+ xpt xoff)) ) ; inc Y (setq ypt (+ ypt yoff)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog04e () (graphscr) ; get center point and dimensions (prompt "\nDraw mesh, X function") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq chgt (getdist pnt0 "\nEnter curve height:")) ; ang inc (setq xanginc (/ 360.0 xtimes)) ; start (setq ypt (nth 1 pnt0)) ; start mesh (command ".3DMESH" ytimes xtimes) (repeat ytimes (setq xpt (nth 0 pnt0)) (setq xang 0.0) (repeat xtimes ; curve value (setq cval (sin (dtr xang))) ; compute height (setq zpt (* cval chgt)) ; add point to mesh (setq pntc (list xpt ypt zpt)) (command pntc) ; inc X (setq xpt (+ xpt xoff)) ; inc ang (setq xang (+ xang xanginc)) ) ; inc Y (setq ypt (+ ypt yoff)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog04f () (graphscr) ; get center point and dimensions (prompt "\nDraw mesh, X and Y function") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq chgt (getdist pnt0 "\nEnter curve height:")) ; ang inc (setq xanginc (/ 360.0 xtimes)) (setq yanginc (/ 360.0 ytimes)) ; start (setq ypt (nth 1 pnt0)) (setq yang 0.0) ; start mesh (command ".3DMESH" ytimes xtimes) (repeat ytimes (setq xpt (nth 0 pnt0)) (setq xang 0.0) (repeat xtimes ; curve value (setq cval (* (sin (dtr xang)) (cos (dtr yang)))) ; compute height (setq zpt (* cval chgt)) ; add point to mesh (setq pntc (list xpt ypt zpt)) (command pntc) ; inc X (setq xpt (+ xpt xoff)) ; inc ang (setq xang (+ xang xanginc)) ) ; inc Y (setq ypt (+ ypt yoff)) ; inc ang (setq yang (+ yang yanginc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog04g () (graphscr) ; get center point and dimensions (prompt "\nDraw mesh, entereed expression for height") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq chgt (getdist pnt0 "\nEnter curve height:")) (setq cexp (getstring "\nEnter curve expression:")) ; ang inc (setq xanginc (/ 360.0 xtimes)) (setq yanginc (/ 360.0 ytimes)) ; start (setq ypt (nth 1 pnt0)) (setq yang 0.0) ; start mesh (command ".3DMESH" ytimes xtimes) (repeat ytimes (setq xpt (nth 0 pnt0)) (setq xang 0.0) (repeat xtimes ; curve value (setq cval (eval (read cexp))) ; compute height (setq zpt (* cval chgt)) ; add point to mesh (setq pntc (list xpt ypt zpt)) (command pntc) ; inc X (setq xpt (+ xpt xoff)) ; inc ang (setq xang (+ xang xanginc)) ) ; inc Y (setq ypt (+ ypt yoff)) ; inc ang (setq yang (+ yang yanginc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog04h () (graphscr) ; get center point and dimensions (prompt "\nDraw rectangles, entered expression for height") (setq pnt0 (getpoint "\nPick start center:")) (setq xtimes (getint "\nEnter repeat X times:")) (setq ytimes (getint "\nEnter repeat Y times:")) (setq xoff (getdist pnt0 "\nEnter X offset:")) (setq yoff (getdist pnt0 "\nEnter Y offset:")) (setq xdim (getdist pnt0 "\nEnter X rectangle side:")) (setq ydim (getdist pnt0 "\nEnter Y rectangle side:")) (setq shgt (getdist pnt0 "\nEnter start rectangle height:")) (setq ehgt (getdist pnt0 "\nEnter end rectangle height:")) (setq cexp (getstring "\nEnter curve expression:")) ; ang inc (setq xanginc (/ 360.0 xtimes)) (setq yanginc (/ 360.0 ytimes)) ; start (setq ypt (nth 1 pnt0)) (setq yang 0.0) ; start selection list (setq objs (ssadd)) (repeat ytimes (setq xpt (nth 0 pnt0)) (setq xang 0.0) (repeat xtimes ; curve value (setq cval (eval (read cexp))) ; compute height (setq zhgt (+ shgt (* cval (- ehgt shgt)))) ; location (setq pntc (list xpt ypt (nth 2 pnt0))) ; draw rectangle (dorectcen pntc xdim ydim) (command ".ZOOM" "e") ; extrude (command ".EXTRUDE" "last" "" zhgt) ; add to selection list (setq objs (ssadd (entlast) objs)) ; inc X (setq xpt (+ xpt xoff)) ; inc ang (setq xang (+ xang xanginc)) ) ; inc Y (setq ypt (+ ypt yoff)) ; inc ang (setq yang (+ yang yanginc)) ) ; union objs (command ".UNION" objs "") (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog05 () (graphscr) ; get center point and dimensions (prompt "\nDraw rotated rectangles") (setq pnt0 (getpoint "\nPick center:")) (setq xside (getdist pnt0 "\nEnter X side:")) (setq yside (getdist pnt0 "\nEnter Y side:")) (setq ntimes (getint "\nEnter number repeats:")) ; compute inc (setq anginc (/ 360.0 ntimes)) (setq ang 0) (repeat ntimes ; draw rectangle by corner points (setq pnt1 (list (+ (nth 0 pnt0) xside) (+ (nth 1 pnt0) yside) (nth 2 pnt0))) ; draw rectangle (command ".RECTANGLE" pnt0 pnt1) (command ".ZOOM" "e") (command ".ROTATE" "last" "" pnt0 ang) ; inc ang (setq ang (+ ang anginc)) ) (princ) ) ; -------------------------------------------------------------------------- (defun prog05a (pnt0 xside yside ntimes / anginc ang pnt1) ; draw rotated rectangles, origin at bottom-left corner ; center, X side, Y side, number of times ; compute inc (setq anginc (/ 360.0 ntimes)) (setq ang 0) (repeat ntimes ; draw rectangle by corner points (setq pnt1 (list (+ (nth 0 pnt0) xside) (+ (nth 1 pnt0) yside) (nth 2 pnt0))) ; draw rectangle (command ".RECTANGLE" pnt0 pnt1) (command ".ZOOM" "e") (command ".ROTATE" "last" "" pnt0 ang) ; inc ang (setq ang (+ ang anginc)) ) (princ) ) ; ---------------------------------------- (defun drwg05_01 () (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog05a pntc 10.0 10.0 8) (prog05a pntc 7.07 7.07 8) (prog05a pntc 5.0 5.0 8) (command ".ZOOM" "e") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog05b (pnt0 nsides xside ntimes / anginc ang pnt1) ; draw rotated polygons, origin at bottom-left edge ; compute inc (setq anginc (/ 360.0 ntimes)) (setq ang 0) (repeat ntimes ; endpoint of edge (setq pnt1 (list (+ (nth 0 pnt0) xside) (nth 1 pnt0) (nth 2 pnt0))) ; draw polygon (command ".POLYGON" nsides "edge" pnt0 pnt1) (command ".ZOOM" "e") (command ".ROTATE" "last" "" pnt0 ang) ; inc ang (setq ang (+ ang anginc)) ) (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg05_02 () (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog05b pntc 6 10 12) (prog05b pntc 6 5 12) (command ".ZOOM" "e") (princ) ) ; ---------------------------------------- (defun drwg05_03 () (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog05b pntc 6 10 12) (prog05b pntc 6 7.5 12) (prog05b pntc 6 5 12) (command ".ZOOM" "e") (princ) ) ; ---------------------------------------- (defun drwg05_04 () (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog05b pntc 8 8 8) (prog05b pntc 8 6 8) (prog05b pntc 8 4 8) (prog05b pntc 8 2 8) (command ".ZOOM" "e") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog06a (pnt0 psides pxside ptimes pthk player / pnt1 pnt2 pnt3) ; polygon start point of bottom edge ; set current layer (command ".LAYER" "MAKE" player "") ; endpoint of edge (setq pnt1 pnt0) (setq pnt2 (list (+ (nth 0 pnt1) pxside) (nth 1 pnt1) (nth 2 pnt1))) ; draw ploygon (command ".POLYGON" psides "edge" pnt1 pnt2) (command ".ZOOM" "e") ; point inside polygon (setq pnt3 (polar pnt1 (dtr (/ 360.0 psides)) (/ pxside 2.0))) ;(setq pnt3 (list (+ (nth 0 pnt1) (/ pxside 2.0)) (+ (nth 1 pnt1) pthk) (nth 2 pnt1))) ;offset thickness (command ".OFFSET" pthk pnt1 pnt3 "") ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg06_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog06a pntc 6 10 12 0.25 "LAYER01") (prog06a pntc 6 5 12 0.25 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- (defun drwg06_02 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog06a pntc 6 10 12 0.25 "LAYER01") (prog06a pntc 6 7.5 12 0.25 "LAYER02") (prog06a pntc 6 5 12 0.25 "LAYER03") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- (defun drwg06_03 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog06a pntc 8 8 8 0.25 "LAYER01") (prog06a pntc 8 6 8 0.25 "LAYER02") (prog06a pntc 8 4 8 0.25 "LAYER03") (prog06a pntc 8 2 8 0.25 "LAYER04") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; ---------------------------------------- (defun drwg06_04 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog06a pntc 8 8 8 0.25 "LAYER01") (prog06a pntc 8 6 8 0.25 "LAYER02") (prog06a pntc 8 4 8 0.25 "LAYER03") (prog06a pntc 8 2 8 0.25 "LAYER04") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (command ".EXTRUDE" "last" "" 0.5) ; include taper for versions prior to 2007 ;(command ".EXTRUDE" "last" "" 0.25 "0") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun prog06b (pnt0 psides pxside ptimes pthk player / pnt1 pnt2 pnt3) ; polygon midpoint of bottom edge ; set current layer (command ".LAYER" "MAKE" player "") ; endpoints of edge (setq pnt1 (list (- (nth 0 pnt0) (/ pxside 2.0)) (nth 1 pnt0) (nth 2 pnt0))) (setq pnt2 (list (+ (nth 0 pnt0) (/ pxside 2.0)) (nth 1 pnt0) (nth 2 pnt0))) ; draw ploygon (command ".POLYGON" psides "edge" pnt1 pnt2) (command ".ZOOM" "e") ; point inside polygon (setq pnt3 (polar pnt1 (dtr (/ 360.0 psides)) (/ pxside 2.0))) ;(setq pnt3 (list (+ (nth 0 pnt1) (/ pxside 2.0)) (+ (nth 1 pnt1) pthk) (nth 2 pnt1))) ;offset thickness (command ".OFFSET" pthk pnt1 pnt3 "") ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg06_05 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog06b pntc 6 10 12 0.25 "LAYER01") (prog06b pntc 6 7.5 12 0.25 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun prog06c (pnt0 psides prad ptimes pthk player / pnt1) ; polygon center ; set current layer (command ".LAYER" "MAKE" player "") ; cneter of polygon (setq pnt1 pnt0) ; draw ploygon (command ".POLYGON" psides pnt1 "I" prad) (command ".ZOOM" "e") ;offset thickness (command ".POLYGON" psides pnt1 "I" (- prad pthk)) ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg06_06 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog06c pntc 6 10 5 0.175 "LAYER01") (prog06c pntc 4 8.6 5 0.175 "LAYER02") (prog06c pntc 5 6.0 4 0.175 "LAYER03") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun prog06d (pnt0 psides pxside ptimes pthk pyoff player / pnt1 pnt2 pnt3) ; polygon start point of bottom edge w/Y offset ; set current layer (command ".LAYER" "MAKE" player "") ; endpoint of edge (setq pnt1 (list (nth 0 pnt0) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) (setq pnt2 (list (+ (nth 0 pnt1) pxside) (nth 1 pnt1) (nth 2 pnt1))) ; draw ploygon (command ".POLYGON" psides "edge" pnt1 pnt2) (command ".ZOOM" "e") ; point inside polygon (setq pnt3 (polar pnt1 (dtr (/ 360.0 psides)) (/ pxside 2.0))) ;(setq pnt3 (list (+ (nth 0 pnt1) (/ pxside 2.0)) (+ (+ (nth 1 pnt1) pthk) pyoff) (nth 2 pnt1))) ;offset thickness (command ".OFFSET" pthk pnt1 pnt3 "") ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg06_07 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog06d pntc 6 10 12 0.35 5.0 "LAYER01") (prog06d pntc 6 8.5 12 0.35 1.25 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun prog06e (pnt0 psides pxside ptimes pthk pyoff player / pnt1 pnt2 pnt3) ; polygon midpoint of bottom edge w/Y offset ; set current layer (command ".LAYER" "MAKE" player "") ; endpoints of edge (setq pnt1 (list (- (nth 0 pnt0) (/ pxside 2.0)) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) (setq pnt2 (list (+ (nth 0 pnt0) (/ pxside 2.0)) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) ; draw ploygon (command ".POLYGON" psides "edge" pnt1 pnt2) (command ".ZOOM" "e") ; point inside polygon (setq pnt3 (polar pnt1 (dtr (/ 360.0 psides)) (/ pxside 2.0))) ;(setq pnt3 (list (+ (nth 0 pnt1) (/ pxside 2.0)) (+ (nth 1 pnt1) pthk) (nth 2 pnt1))) ;offset thickness (command ".OFFSET" pthk pnt1 pnt3 "") ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- (defun prog06f (pnt0 psides prad ptimes pthk pyoff player / pnt1) ; polygon center w/Y offset ; set current layer (command ".LAYER" "MAKE" player "") ; cneter of polygon (setq pnt1 (list (nth 0 pnt0) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) ; draw ploygon (command ".POLYGON" psides pnt1 "I" prad) (command ".ZOOM" "e") ;offset thickness (command ".POLYGON" psides pnt1 "I" (- prad pthk)) ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg06_08 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog06e pntc 6 10 12 0.35 7.5 "LAYER01") (prog06e pntc 6 7.5 12 0.35 3.5 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; ---------------------------------------- (defun drwg06_09 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog06f pntc 6 10 5 0.35 5.0 "LAYER01") (prog06f pntc 8 15 5 0.35 2.5 "LAYER02") (prog06f pntc 5 6.0 4 0.35 6.0 "LAYER03") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun dolpolygon (pnts psides pxside / spnt npnt cang tang) ; line polygon start point of start point bottom edge ; compute turning ang (setq cang (/ 360.0 psides)) ; set initial ang (setq tang 0.0) ; start PLINE (setq spnt pnts) ; draw polygon (command ".PLINE" spnt) (repeat psides ; compute next point (setq npnt (polar spnt (dtr tang) pxside)) ; add point (command npnt) ; inc ang (setq tang (+ tang cang)) ; set next start point (setq spnt npnt) ) ; close PLINE (command "c") (princ) ) ; -------------------------------------------------------------------------- (defun prog07a (pnt0 psides pxside ptimes pthk player / pnt1 pnt3) ; polygon start point of bottom edge ; set current layer (command ".LAYER" "MAKE" player "") ; start point of edge (setq pnt1 pnt0) ; draw ploygon (dolpolygon pnt0 psides pxside) (command ".ZOOM" "e") ; point inside polygon (setq pnt3 (polar pnt1 (dtr (/ 360.0 psides)) (/ pxside 2.0))) ;(setq pnt3 (list (+ (nth 0 pnt1) (/ pxside 2.0)) (+ (nth 1 pnt1) pthk) (nth 2 pnt1))) ;offset thickness (command ".OFFSET" pthk pnt1 pnt3 "") ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg07_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog07a pntc 6 10 12 0.35 "LAYER01") (prog07a pntc 6 5 12 0.35 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun doaipolygon (pnts psides pxside / spnt npnt cang tang) ; concave arc polygon start point of start point bottom edge ; compute turning ang (setq cang (/ 360.0 psides)) ; set initial ang (setq tang (- 180.0 cang)) ; start PLINE (setq spnt pnts) ; draw polygon (command ".PLINE" spnt "a") (repeat psides ; compute next point (setq npnt (polar spnt (dtr tang) pxside)) ; add point (command "r" (* pxside 1.0) npnt) ; inc ang (setq tang (- tang cang)) ; set next start point (setq spnt npnt) ) ; close PLINE (command "cl") (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog08a (pnt0 psides pxside ptimes pthk player / pnt1 pnt3) ; polygon start point of bottom edge ; set current layer (command ".LAYER" "MAKE" player "") ; start point of edge (setq pnt1 pnt0) ; draw ploygon (doaipolygon pnt0 psides pxside) (command ".ZOOM" "e") ; point inside polygon (setq pnt3 (polar pnt1 (dtr (/ 360.0 psides)) (/ pxside 2.0))) ;(setq pnt3 (list (+ (nth 0 pnt1) (/ pxside 2.0)) (+ (nth 1 pnt1) pthk) (nth 2 pnt1))) ;offset thickness (command ".OFFSET" pthk pnt1 pnt3 "") ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg08_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog08a pntc 6 10 12 0.35 "LAYER01") (prog08a pntc 6 5 12 0.35 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun doaopolygon (pnts psides pxside / spnt npnt cang tang) ; convex arc polygon start point of start point bottom edge ; compute turning ang (setq cang (/ 360.0 psides)) ; set initial ang (setq tang 0.0) ; start PLINE (setq spnt pnts) ; draw polygon (command ".PLINE" spnt "a") (repeat psides ; compute next point (setq npnt (polar spnt (dtr tang) pxside)) ; add point (command "r" (* pxside 0.5) npnt) ; inc ang (setq tang (+ tang cang)) ; set next start point (setq spnt npnt) ) ; close PLINE (command "cl") (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog09a (pnt0 psides pxside ptimes pthk player / pnt1 pnt3) ; polygon start point of bottom edge ; set current layer (command ".LAYER" "MAKE" player "") ; start point of edge (setq pnt1 pnt0) ; draw ploygon (doaopolygon pnt0 psides pxside) (command ".ZOOM" "e") ; point inside polygon (setq pnt3 (polar pnt1 (dtr (/ 360.0 psides)) (/ pxside 2.0))) ;(setq pnt3 (list (+ (nth 0 pnt1) (/ pxside 2.0)) (+ (nth 1 pnt1) pthk) (nth 2 pnt1))) ;offset thickness (command ".OFFSET" pthk pnt1 pnt3 "") ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg09_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog09a pntc 6 10 12 0.35 "LAYER01") (prog09a pntc 6 5 12 0.35 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun prog10f (pnt0 prad ptimes pthk pyoff player / pnt1) ; circle center w/Y offset ; set current layer (command ".LAYER" "MAKE" player "") ; center of circle (setq pnt1 (list (nth 0 pnt0) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) ; draw circle (command ".CIRCLE" pnt1 prad) (command ".ZOOM" "e") ;offset thickness (command ".CIRCLE" pnt1 (- prad pthk)) ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg10_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog10f pntc 5 12 0.25 5.0 "LAYER01") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; ---------------------------------------- (defun drwg10_02 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog10f pntc 5 12 0.25 7.5 "LAYER01") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun prog11f (pnt0 pxrad pyrad ptimes pthk pyoff player / pnt1 pnt2) ; ellipse center w/Y offset ; set current layer (command ".LAYER" "MAKE" player "") ; center of ellipse (setq pnt1 (list (nth 0 pnt0) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) ; draw ellipses (setq pnt2 (list (- (nth 0 pnt1) pxrad) (nth 1 pnt1) (nth 2 pnt1))) (command ".ELLIPSE" "c" pnt1 pnt2 pyrad) ;offset thickness (setq pnt2 (list (+ (- (nth 0 pnt1) pxrad) pthk) (nth 1 pnt1) (nth 2 pnt1))) (command ".ELLIPSE" "c" pnt1 pnt2 (- pyrad pthk)) ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg11_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog11f pntc 7.5 2.5 12 0.25 5.0 "LAYER01") (prog11f pntc 2.5 1.25 6 0.25 3.75 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; ---------------------------------------- (defun drwg11_02 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog11f pntc 8.5 3.5 12 0.15 0 "LAYER01") (prog11f pntc 7.0 3.0 12 0.15 0 "LAYER02") (prog11f pntc 7.5 2.5 12 0.15 0 "LAYER03") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun doepolygon (pnt0 psides pxrad pyrad / npnt cang tang xpt ypt) ; elliptical polygon by center ; compute turning ang (setq cang (/ 360.0 psides)) ; set initial ang (setq tang 0.0) ; draw ploygon (command ".PLINE") (repeat psides ; compute next point (setq xpt (+ (nth 0 pnt0) (* pxrad (sin (dtr tang))))) (setq ypt (+ (nth 1 pnt0) (* pyrad (cos (dtr tang))))) (setq npnt (list xpt ypt (nth 2 pnt0))) ; add point (command npnt) ; inc ang (setq tang (+ tang cang)) ) ; close PLINE (command "c") (princ) ) ; -------------------------------------------------------------------------- (defun prog12f (pnt0 psides pxrad pyrad ptimes pthk pyoff player / pnt1 pnt2) ; ellipse polygon w/Y offset ; set current layer (command ".LAYER" "MAKE" player "") ; center of polygon (setq pnt1 (list (nth 0 pnt0) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) ; draw polygon (doepolygon pnt1 psides pxrad pyrad) ;offset thickness (doepolygon pnt1 psides (- pxrad pthk) (- pyrad pthk)) ; convert to regions (command ".REGION" "all" "") ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg12_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog12f pntc 5 2.5 7.5 12 0.35 6.25 "LAYER01") (prog12f pntc 5 2.5 2.5 6 0.35 2.5 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun prog13f (pnt0 prads prade ptimes pthk pyoff player / pnt1 ranginc rang pradinc prad obj1 obj2) ; circle by center, changing radius w/Y offset ; set current layer (command ".LAYER" "MAKE" player "") ; angs for repeat (setq ranginc (/ 360.0 ptimes)) (setq rang 0.0) ; radius inc (setq pradinc (/ (- prade prads) ptimes)) (setq prad prads) (repeat ptimes ; center of circle (setq pnt1 (list (nth 0 pnt0) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) ; draw circles (command ".CIRCLE" pnt1 prad) (command ".REGION" "last" "") (setq obj1 (ssadd (entlast))) ;offset thickness (command ".CIRCLE" pnt1 (- prad pthk)) (command ".REGION" "last" "") (setq obj2 (ssadd (entlast))) ; subtract inside from outside (command ".SUBTRACT" obj1 "" obj2 "") ; rotate (command ".ROTATE" "last" "" pnt0 rang) ; inc rotation (setq rang (+ rang ranginc)) ; inc radius (setq prad (+ prad pradinc)) ) ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg13_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog13f pntc 2.0 5.0 12 0.2 5.0 "LAYER01") (prog13f pntc 5.0 2.5 12 0.2 5.0 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- (defun prog14f (pnt0 prad ptimes pthk pyoffs pyoffe player / pnt1 ranginc rang pyoffinc pyoff obj1 obj2) ; circle by center, changing Y offset ; set current layer (command ".LAYER" "MAKE" player "") ; angs for repeat (setq ranginc (/ 360.0 ptimes)) (setq rang 0.0) ; offset inc (setq pyoffinc (/ (- pyoffe pyoffs) ptimes)) (setq pyoff pyoffs) (repeat ptimes ; center of circle (setq pnt1 (list (nth 0 pnt0) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) ; draw circles (command ".CIRCLE" pnt1 prad) (command ".REGION" "last" "") (setq obj1 (ssadd (entlast))) ;offset thickness (command ".CIRCLE" pnt1 (- prad pthk)) (command ".REGION" "last" "") (setq obj2 (ssadd (entlast))) ; subtract inside from outside (command ".SUBTRACT" obj1 "" obj2 "") ; rotate (command ".ROTATE" "last" "" pnt0 rang) ; inc rotation (setq rang (+ rang ranginc)) ; inc offset (setq pyoff (+ pyoff pyoffinc)) ) ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg14_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog14f pntc 5.0 12 0.2 2.5 5.0 "LAYER01") (prog14f pntc 2.5 12 0.2 5.0 7.5 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun dotrefoil (pnt0 lrad crad / pnt1 pnt2 pnt3 obj1) ; first circle (setq pnt1 (polar pnt0 (dtr 90) lrad)) (command ".CIRCLE" pnt1 crad) ; make region (command ".REGION" "last" "" ) ; place into selection list (setq obj1 (ssadd (entlast))) ; second circle (setq pnt2 (polar pnt0 (dtr 210) lrad)) (command ".CIRCLE" pnt2 crad) ; make region (command ".REGION" "last" "" ) ; place into selection list (setq obj1 (ssadd (entlast) obj1)) ; third circle (setq pnt3 (polar pnt0 (dtr 330) lrad)) (command ".CIRCLE" pnt3 crad) ; make region (command ".REGION" "last" "" ) ; place into selection list (setq obj1 (ssadd (entlast) obj1)) ; union are three (command ".UNION" obj1 "") (princ) ) ; -------------------------------------------------------------------------- ; -------------------------------------------------------------------------- (defun prog15f (pnt0 prad ptimes pthk pyoff player / pnt1) ; circle center w/Y offset ; set current layer (command ".LAYER" "MAKE" player "") ; center of circle (setq pnt1 (list (nth 0 pnt0) (+ (nth 1 pnt0) pyoff) (nth 2 pnt0))) ; draw circle (dotrefoil pnt1 prad prad) (command ".ZOOM" "e") ;offset thickness (dotrefoil pnt1 prad (- prad pthk)) ; subtract inside from outside (command ".SUBTRACT" "all" "r" "last" "" "last" "") ; rotate it (command ".ARRAY" "last" "" "P" pnt0 ptimes "360" "Y") ; hide layer (command ".LAYER" "SET" "0" "LOCK" player "FREEZE" player "") (princ) ) ; -------------------------------------------------------------------------- ; ---------------------------------------- (defun drwg15_01 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog15f pntc 5 6 0.35 2.5 "LAYER01") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; ---------------------------------------- (defun drwg15_02 () (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ERASE" "all" "") (setq pntc (list 0.0 0.0 0.0)) (prog15f pntc 5 6 0.35 10.0 "LAYER01") (prog15f pntc 2.5 6 0.35 8.0 "LAYER02") (command ".LAYER" "UNLOCK" "*" "THAW" "*" "ON" "*" "") (command ".ZOOM" "e") (command ".UNION" "all" "") (princ) ) ; ---------------------------------------- ; --------------------------------------------------------------------------