凑个热闹,
(defun XD::List:GroupByNum (lst num / ls ret)
(if (= (rem (length lst) num) 0)
(progn
(setq ls nil)
(repeat (/ (length lst) num)
(repeat num
(setq ls (cons (car lst) ls)
lst (cdr lst)
)
)
(setq ret (append
ret
(list (reverse ls))
)
ls nil
)
)
)
)
ret
)
(defun c:tt ()
(defun _setelev (pt elev)
(list (car pt) (cadr pt) elev)
)
;;;;;;;;;;;;;;;;;;;;;
(defun _drawPolyline (pts)
(setq pts (mapcar
'(lambda (x)
(list (car x) (cadr x))
)
pts
)
)
(setq points (vlax-make-safearray vlax-vbDouble (cons 0 (1- (* 2
(length pts)
)
)
)
)
)
(vlax-safearray-fill points (apply
'append
pts
)
)
(setq plineObj (vla-AddLightWeightPolyline ms points))
)
;;;;;;;;;;;;;;;;;;;;;
(defun _drawline ()
(setq line (vlax-invoke ms 'addline first extMax)
ang (angle first extmax)
templen 0.
)
(setq i 0)
(repeat #div
(setq lineObj (vla-Offset line (* (setq i (1+ i))
offsetdist
)
)
lineObj (car (vlax-safearray->list (vlax-variant-value lineObj)))
intPoints (vlax-Invoke lineObj 'IntersectWith circleObj
acExtendboth
)
ints (XD::List:GroupByNum intPoints 3)
)
(if (not (equal ang (apply
'angle
ints
) 1
)
)
(setq ints (reverse ints))
)
(if (= (rem i 2) 0)
(setq ept (car ints)
ints (list (last ints) ept)
an1 (* 3 (/ pi 4))
an2 pi
)
(setq ept (last ints)
an1 (/ pi 2)
an2 0
)
)
(if (> (apply
'distance
ints
) templen
)
(progn
(setq mid (polar (polar ept (/ pi 2) (/ (abs offsetdist) 2.0)) an2
#dis
)
p2 (polar ept (/ pi 2) (abs offsetdist))
)
)
(progn
(setq p2 (car temp)
mid (polar (polar p2 (- (/ pi 2.0)) (/ (abs offsetdist) 2.0))
an2 #dis
)
ept (polar p2 (- (/ pi 2)) (abs offsetdist))
)
)
)
(setq pts (cons p2 pts)
pts (cons mid pts)
pts (cons ept pts)
temp ints
templen (apply
'distance
ints
)
)
(vla-delete lineobj)
)
(vla-delete line)
(if (= (rem #div 2) 0)
(setq pts (cons end pts))
(setq pts (cons extmin pts))
)
(_drawPolyline pts)
)
;;;;;;;;;;;;;;;;;;;;;
(defun _drawcircle ()
(setq circleObj (vla-addcircle ms (vlax-3d-point #cen) #r)
offsetdist (- (/ (* 2 #r) #div))
)
(vla-getboundingbox circleobj 'extMin 'extMax)
(setq extMin (_setelev (vlax-safearray->list extMin) 0.0)
extMax (_setelev (vlax-safearray->list extMax) 0.0)
first (list (car extmin) (cadr extmax) 0.0)
end (list (car extmax) (cadr extmin) 0.0)
pts (list first)
)
(_drawline)
)
;;;;;;;;;;;;;;;;;;;;;
(if (not #r)
(setq #r 100)
)
(if (not #dis)
(setq #dis 10)
)
(if (setq r (getreal (strcat "\n半径<" (vl-prin1-to-string #r) ">:")))
(setq #r r)
)
(if (setq dis (getreal (strcat "\n尖角水平距离<"
(vl-prin1-to-string #dis) ">:"
)
)
)
(setq #dis dis)
)
(setq doc (vla-get-activedocument (vlax-get-acad-object))
ms (vla-get-modelspace doc)
)
(vlax-invoke-method doc 'StartUndoMark)
(while (and
(setq #div (getint "\n等分数<退出>:"))
(setq #cen (getpoint "\n圆心<退出>"))
)
(_drawcircle)
)
(vlax-invoke-method doc 'EndUndoMark)
(princ)
)
|