本帖最后由 llsheng_73 于 2014-9-17 23:04 编辑
- (defun lwplxy(e)(vl-remove'nil(mapcar'(lambda(x)(if(=(car x)10)(cdr x)))(entget e))))
- (defun lwplxy(e)(mapcar'cdr(vl-remove-if'(lambda(x)(/=(car x)10))(entget e))))
两个办法没本质区别,也没测试过哪一种会更快或者没多大出入
- ((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 Plinexy(e / p a ltype )
- (setq a(entget e)ltype(cdr(assoc 0 a)))
- (if(assoc 90 a)(vl-remove'nil(mapcar'(lambda(x)(if(=(car x)10)(cdr x)))(entget e)))
- (progn(while(/=(cdr(assoc 0(setq p(cons(cdr(assoc 10 a))p)e(entnext e)a(entget e))))"SEQEND"))
- (cdr(reverse p)))))
|