求出了所有交点,不是是否有些多余
- (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:main( / ss n i j ent1 ent2 points)
- (setq ss (ssget))
- (if ss
- (setq n (sslength ss))
- )
- (setq i 0 j 0)
- (while (< i n)
- (setq j (1+ i))
- (setq ent1 (ssname ss i))
- (while (< j n)
- (setq ent2 (ssname ss j))
- (setq points (append points (getinterpoint ent1 ent2)))
- (setq j (1+ j))
- )
- (setq i (1+ i))
- )
- (Princ points)
- (princ (strcat "\n共有交点" (itoa (length points)) "个"))
- (princ)
- )
|