-
- (vl-load-com)
- (defun C:zx( / dispt1 dispt2 dispt3 dispt4 e1 e2 i ii mindis obj1 obj2 pt1 pt2 pt3 pt4 ss sslen)
- (setq SS (ssget '((0 . "LINE,ARC,POLYLINE,LWPOLYLINE,CIRCLE,SPLINE"))))
- (setq i 0)
- (setq sslen (sslength ss))
- (repeat (1- sslen)
- (setq E1 (ssname SS i))
- (setq ii (1+ i))
- (repeat (- sslen 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 dispt1 (th-per pt1 obj2))
- (setq dispt2 (th-per pt2 obj2))
- (setq dispt3 (th-per pt3 obj1))
- (setq dispt4 (th-per pt4 obj1))
- ( (setq mindis (min dispt1 dispt2 dispt3 dispt4)) 0)
- )
- (command "._OFFSET" (/ mindis 2) e1 pt3 "")
- )
- (setq ii (1+ ii))
- )
- (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))))
- )
- )
现在求平行线的中线我是用OFFSET实线的,想求一个用entmake实线的,而且这版存在中线有时重复的问题。而且最好能比平行线每边都长一点。
mixg4a1r5pa.JPG
xchrik3ajyj.gif
|