OK, I have made a few changes in this version:
- All points are relative - no matter where you draw your circle in your drawing, the points written to file will be relative to the Center of respective circles.
- The Bottom Left, and bottom right points will be spaced at 0.05, irrelevant of the radius of the circle.
- The Points relative the smaller circles are written beneath the main results as a one-liner.
- (defun c:cCut (/ doc spc cEnt root ofile tNum tmp1 tmp2 theta tmp3 tmp4 bsRad cCen cNum cAng i cPt str) (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (setvar "PDMODE" 3) ; Point Style (setvar "PDSIZE" 0.01) ; Point Size (or cut:out (setq cut:out 0.05)) (or cut:spc (setq cut:spc 0.007)) (or cut:row (setq cut:row 0.02)) (or cut:cir (setq cut:cir 0.125)) (if (and (setq cEnt (car (entsel "\nSelect Base Circle: "))) (eq "CIRCLE" (cdr (assoc 0 (entget cEnt))))) (progn (setq root (strcat (getvar "DWGPREFIX") (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4))) tNum 0. col 1 ofile (open (strcat root "_BASE.csv") "w")) (write-line "Centre,Top,Right,Left,Bottom Right,Bottom Left" ofile) (initget 4) (setq tmp1 (getreal (strcat "\nSpecify Spacing from Edge : "))) (or (not tmp1) (setq cut:out tmp1)) (initget 4) (setq tmp2 (getreal (strcat "\nSpecify Circle Spacing : "))) (or (not tmp2) (setq cut:spc tmp2)) (initget 4) (setq tmp3 (getreal (strcat "\nSpecify Row Spacing : "))) (or (not tmp3) (setq cut:row tmp3)) (initget 6) (setq tmp4 (getreal (strcat "\nSpecify Inner Circle Radius : "))) (or (not tmp4) (setq cut:cir tmp4)) (setq bsRad (- (cdr (assoc 40 (entget cEnt))) cut:out cut:cir) cCen (cdr (assoc 10 (entget cEnt)))) (while (and (not (minusp bsRad)) (< cut:cir bsRad)) (setq cNum (fix (/ (* 2 pi bsRad) (+ (* 2 cut:cir) cut:spc))) cAng (/ (* 2 pi) cNum) i 0 str "") (while (< i cNum) (vla-put-color (vla-addCircle spc (vlax-3D-point (setq cPt (polar cCen (* i cAng) bsRad))) cut:cir) col) (setq theta (atan (/ (/ 0.025 cut:cir) (sqrt (- 1. (expt (/ 0.025 cut:cir) 2)))))) (foreach x (mapcar '(lambda (x) (mapcar '- x cCen)) (list cPt (polar cPt (/ pi 2) cut:cir) (polar cPt 0 cut:cir) (polar cPt pi cut:cir) (polar cPt (+ (/ (* 3 pi) 2) theta) cut:cir) (polar cPt (- (/ (* 3 pi) 2) theta) cut:cir))) (vla-addPoint spc (vlax-3D-point (mapcar '+ cCen x))) (setq str (strcat str (vl-princ-to-string x) (chr 44)))) (write-line str ofile) (setq i (1+ i) tNum (1+ tNum) str "")) (setq bsRad (- bsRad (* 2 cut:cir) cut:row) col (abs (- col 3)))) (princ (strcat "\n>")) (write-line "Points Rel. Inner Circle:" ofile) (write-line (strcat "(0 0 0),(0 " (rtos cut:cir) " 0),(" (rtos cut:cir) " 0 0),(" (rtos (* -1. cut:cir)) " 0 0),(" (rtos (* cut:cir (sin theta))) (chr 32) (rtos (* -1. cut:cir (cos theta))) " 0),(" (rtos (* -1. cut:cir (sin theta))) (chr 32) (rtos (* -1. cut:cir (cos theta))) " 0)") ofile) (close ofile)) (princ "\n Incorrect Selection ")) (princ))
|