llsheng_73 发表于 2013-10-18 12:51
这就是程序的一部分,你可以把它当成一个函数用到你程序中,先测试下返回的表是什么样子自己决定怎么用它 ... - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defun Plinexy(e / p a b n ob q et d d1 en et) ;;多线段节点坐标(滤掉了多余点,未处理假闭合)
- (setq a(entget e)ob(vlax-ename->vla-object e)et(cdr(assoc 0 a))n 0 p nil d nil)
- (cond((="LWPOLYLINE"et)
- (repeat(length a)(setq b (nth n a) n (+ n 1))
- (if (= 10 (car b))(progn
- (setq q(list (cadr b) (caddr b))d1(vlax-curve-getDistAtPoint ob q))
- (if p (if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))
- (setq p (list q))))
- )))
- ((="POLYLINE"et)
- (SETQ EN (ENTGET (SETQ E (ENTNEXT E))))
- (WHILE (/= (CDR (ASSOC 0 EN)) "SEQEND")
- (SETQ q (CDR (ASSOC 10 EN))d1(vlax-curve-getDistAtPoint ob q)q(reverse(cdr(reverse q))))
- (if p(if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))
- (setq p (list q)))
- (SETQ EN (ENTGET (SETQ E (ENTNEXT E)))))
- (setq p(reverse p))
- ))
- P)
- ;;;;
- (defun SStoES(s / m n e)
- (if s(progn
- (setq n(sslength s)m 0)
- (while(< m n)
- (setq e(if e(append e(list(ssname s m)))(list(ssname s m)))m(1+ m))))
- )e)
- (defun dzfx(s / e s1 a b c d l)
- (setq ss(SStoES s))
- (if ss(progn
- (foreach e ss(setq ss(subst(list e "" nil)e ss)))
- (foreach e ss
- (setq f(car e)p(plinexy f)f1(assoc(nth 1 e) ss)
- s1(SStoES(ssget"WP" p(list(cons 0 "LWPOLYLINE,POLYLINE")(cons 8 LDK)
- (CONS -4 "<OR")(CONS 70 129)(CONS 70 1)(CONS -4 "OR>")))))
- (if f1(progn
- (setq d(nth 2 f1))
- (foreach a s1(if(member a d)(setq b(assoc a ss)c(nth 1 b)
- ss(subst(subst f c b)b ss)l 0)))
- (setq d(vl-remove-if(FUNCTION(LAMBDA(a)(member a s1)))d))
- (setq ss(subst(subst d(nth 2 f1)f1)f1 ss)l 0)
- ))
- (setq d nil)
- (foreach a s1
- (setq b(assoc a ss)c(nth 1 b)d nil)
- (if(null(member c s1))(setq ss(subst(subst f c b)b ss)l 0)
- (progn(if c(setq b(assoc c ss)
- c(nth 2 b)
- ss(subst(subst(vl-remove a c)c b)b ss)l 0))
- (setq d(if d(append d(list a))(list a))))))
- (setq s1(vl-remove-if(FUNCTION(LAMBDA(a)(member a d)))s1)
- ss(subst(subst s1(nth 2 e)e)e ss)l 0)
- )
- ))
- (princ)
- )
- (setq ddd (ssget '((0 . "lwpolyline") )))
- (setq opo (dzfx ddd))
|