本帖最后由 llsheng_73 于 2017-10-18 17:05 编辑
既然染色一定是人工的,那么前边拓扑部分就由你自己的ARX来完成,毕竟ARX速度要快得多
然后人工染色
最后只需要写一个输出TXT的,如果对点号顺序没特别要求的话,其实很简单
- (defun getcolor(e / c)
- (if(setq e(entget e)c(assoc 62 e))
- (cdr c)
- (cdr(assoc 62(tblsearch"layer"(cdr(assoc 8 e)))))
- ))
- (defun plinexy(e)
- (mapcar'cdr(vl-remove-if'(lambda(x)(/=(car x)10))(entget e)))
- )
- (defun Pldir(pt)
- (<(apply'+(mapcar'(lambda(x y)(-(*(car x)(cadr y))(*(car y)(cadr x))))(cons(last pt)pt)pt))0))
- (defun c:tt(/ s f i e p pt txt c)
- (if(and(setq s(ssget'((0 . "lwpolyline")(-4 . "&")(70 . 1))))
- (setq s(vl-remove-if'(lambda(x)(/=(type x)'ename))(mapcar'cadr(ssnamex s)))
- f(getfiled "" "" "txt" 1))
- (setq txt""f(open f"w")))
- (progn
- (foreach e s
- (foreach i(if(pldir(setq p(plinexy e)))(setq p(reverse p))p)
- (if(not(member i pt))(setq pt(append pt(list i))))
- (setq txt(strcat(itoa(vl-position i pt))"\n"txt)))
- (setq c(getcolor e)
- c(cadr(assoc c(append'((1" 0 0 0 0 0 0 276")
- (2" 0 0 0 0 0 0 260")
- (3" 0 0 0 0 0 0 400")
- (4" 0 0 0 1 0 0 384")
- (5" 0 0 0 3 0 0 384")
- (6" 0 0 25 0 25 0 260")
- (7" 0 0 0 2 0 0 384")
- (8" 0 0 0 0 0 0 384")
- (9" X X X 0 X X XXX"))
- (list(list c(strcat" 0 0 0 0 0 0 "(itoa c)))))))
- txt(strcat"\n"(itoa(length p))c"\n"txt)))
- (setq txt(strcat"\n"(itoa(length s))"\n"txt)
- i(length pt));;;;
- (foreach p(reverse pt)
- (entmakex(mapcar'cons'(0 1 10 40 62)(list"text"(itoa i)p 0.3 1)));;;;
- (setq i(1- i)txt(strcat(rtos(car p)2 4)" "(rtos(cadr p)2 4)"\n"txt)))
- (write-line(strcat(itoa(length pt))"\n\n"txt)f)
- (close f))
- ))
图上好象是ucs坐标的,写出的是世界坐标,可能需要自行处理下
凹所在三角形(n-1点,n点,n+1点)的方向一定与多段线整体方向相反
|