使用选择前先ZOOM A 一下, 我也写了一个,,,跟你有点类似,不过选择方式上不同...- (vl-load-com)
- (defun sscat(ss1 ss2 / i)
- (setq i 0)
- (cond
- ((not ss1) ss2)
- ((not ss2) ss1)
- (t (while (< i (sslength ss2))
- (ssadd (ssname ss2 i) ss1)
- (setq i (1+ i)))
- ss1)
- )
- )
- (defun ssred(ss1 ss2 / i)
- (setq i 0)
- (cond
- ((not ss1) nil)
- ((not ss2) ss1)
- (t (while (< i (sslength ss2))
- (ssdel (ssname ss2 i) ss1)
- (setq i (1+ i)))
- ss1)
- )
- )
- (defun HasInters (ent_1 ent_2 / ax_ent_1 ax_ent_2 intpoints)
- (setq ax_ent_1 (vlax-ename->vla-object ent_1)
- ax_ent_2 (vlax-ename->vla-object ent_2)
- )
- (setq intpoints (vla-intersectwith ax_ent_1 ax_ent_2 acextendboth))
- (setq intpoints (vlax-variant-value intpoints))
- (if (> (vlax-safearray-get-u-bound intpoints 1) 0)
- t
- nil
- )
- );用法:(Strand-SelectObject (car (entsel)) "0" nil)
- (DEFUN Strand-SelectObject (1-SPLINE lays ssOld / ss ssnew i ent ssnew)
- (vla-getboundingbox (vlax-ename->vla-object 1-spline) 'pt1 'pt2)
- (setq ss (ssget "c" (vlax-safearray->list pt1) (vlax-safearray->list pt2) (list '(0 . "SPLINE") (cons 8 lays))))
- ;(setq ss (ssget "x" (list '(0 . "spline") (cons 8 lays)));使用这个比较准确,但速度将减慢很多
- (setq i 0 ssnew (ssadd 1-spline))
- (repeat (sslength ss)
- (setq ent (ssname ss i))
- (if (HasInters ent 1-spline)
- (ssadd ent ssnew)
- )
- (setq i (1+ i))
- )
- (setq ssnew (ssred ssnew ssOld))
- (setq ssOld (sscat ssOld ssnew))
- (setq i 0)
- (repeat (sslength ssnew)
- (setq ssOld (Strand-SelectObject (ssname ssnew i) lays ssOld))
- (setq i (1+ i))
- )
- ssOld
- )
|