(vl-load-com)
(defun C:zx( / np1 np2 np3 np4 e1 e2 i ii mindis obj1 obj2 pt1 pt2 pt3 pt4 ss ssn)
(setq SS (ssget '((0 . "ARC,*LINE,CIRCLE"))))
(setq i 1)
(setq ssn (sslength ss))
(repeat (1- ssn)
(setq E1 (ssname SS i))
(setq ii (1+ i))
(setq E2 (ssname SS ii))
(if (and
E1
E2
(setq OBJ1 (vlax-ename->vla-object E1))
(setq OBJ2 (vlax-ename->vla-object E2))
(setq pt1 (vlax-curve-getstartpoint E1))
(setq pt2 (vlax-curve-getEndPoint E1))
(setq pt3 (vlax-curve-getstartpoint E2))
(setq pt4 (vlax-curve-getEndPoint E2))
(setq np1 (th-per pt1 obj2))
(setq np2 (th-per pt2 obj2))
(setq np3 (th-per pt3 obj1))
(setq np4 (th-per pt4 obj1))
(< (max np1 np2 np3 np4) 8000)
(> (setq mindis (min np1 np2 np3 np4)) 0)
)
(command "._OFFSET" (/ mindis 2) e1 pt3 "")
)
(setq cl_x (entlast))
(command "change" cl_x "" "
" "c" "2" "")
(setq i (1+ i))
)
(princ)
)
;;; ==================================================================
;;; 返回(距离 垂足) 点pt到直线的距离和垂足.
;;; ==================================================================
(defun th-per (pt obj / pt2 dist)
(if (and
pt
obj
)
(setq dist (distance pt (setq pt2 (vlax-curve-getclosestpointto obj pt t))))
)
)