再写了一下,有两个则画两个,如果切点在延长线上,则不画
- (defun GetInterPoint (ent1 ent2 / ax_ent_1 ax_ent_2 intpoints points i)
- (setq ax_ent_1 (vlax-ename->vla-object ent1)
- ax_ent_2 (vlax-ename->vla-object ent2)
- )
- (setq intpoints (vla-intersectwith ax_ent_1 ax_ent_2 acextendnone))
- (setq intpoints (vlax-variant-value intpoints))
- (setq i 0)
- (if (> (vlax-safearray-get-u-bound intpoints 1) 0)
- (repeat (/ (+ 1
- (- (vlax-safearray-get-u-bound intpoints 1)
- (vlax-safearray-get-l-bound intpoints 1)
- )
- )
- 3
- )
- (setq points (append points (list (list
- (vlax-safearray-get-element intpoints i)
- (vlax-safearray-get-element intpoints (+ i 1))
- (vlax-safearray-get-element intpoints (+ i 2))
- )))
- )
- (setq i (+ 3 i))
- )
- )
- points
- )
- (defun c:DrawCircle( / ent pt r entc entl pts i)
- (setq ent (car (entsel "\n选择直线或圆弧...")))
- (setq pt (getpoint "\n输入通过点:"))
- (setq r (getreal "\n输入半径:"))
- (setvar "cmdecho" 0)
- (command "_.circle" pt r)
- (setq entc (entlast))
- (command "_.offset" r ent pt "")
- (setq entl (entlast))
- (setq pts (GetInterpoint entc entl))
- (entdel entc)
- (entdel entl)
- (setq i 0)
- (repeat (length pts)
- (setq pt (nth i pts))
- (command "_.circle" pt r)
- (setq entc (entlast))
- (if (= (length (GetInterpoint entc ent)) 0) (entdel entc))
- (setq i (1+ i))
- )
- (princ)
- )
|