我写了一个通过任意点作已知直线或圆弧相切的最小半径的圆
- (vl-load-com)
- (defun c:DrawCircle( / ent pt pte prCenter r ptr)
- (setq ent (car (entsel "选择直线或圆弧...")))
- (setq ent (vlax-ename->vla-object ent))
- (setq pt (getpoint "选择圆心:"))
- (setq ptr (vlax-curve-getClosestPointTo ent pt))
- (setq pte (vlax-curve-getEndPoint ent))
- (setq pts (vlax-curve-getStartPoint ent))
- (if (or (equal ptr pte) (equal ptr pts))
- (progn
- (setq ptCenter (vlax-safearray->list (vlax-variant-value (vla-get-center ent))))
- (setq r (vla-get-radius ent))
- (setq ptr (polar pt (angle pt ptCenter) (+ r (distance pt ptCenter))))
- )
- )
- (command "_.circle" pt (distance pt ptr))
- (princ)
- )
|