本帖最后由 llsheng_73 于 2023-4-4 16:14 编辑
- (defun PToLn(p p1 p2)
- (trans(mapcar(function -)p1 p)0(mapcar(function -)p1 p2)))
- (defun startend(e)
- (list(vlax-curve-getstartpoint e)
- (vlax-curve-getendpoint e)))
- (defun makepl(arg)
- (entmakex(append(mapcar'cons'(0 100 100 43 370 8 62 39 6)(append'("LWPOLYLINE""AcDbEntity""AcDbPolyline")(cddr arg)))
- (cons(cons 90(length(car arg)))(cons(cons 70(if(cadr arg)(cadr arg)0))(mapcar'(lambda(x)(cons 10 x))(car arg)))))))
- (defun c:tt(/ ss pt i e)
- (vl-load-com)
- (and(setq i 0 ss(ssget'((-4 . "<or")(0 . "line")(-4 . "<and")(0 . "*polyline")(-4 . "=")(90 . 2)(-4 . "and>")(-4 . "or>"))))
- (vl-every(function set)'(p1 p2)(startend(ssname ss 0)))
- (setq pt(list(List(vl-list* 0 0 0 p1))(list(vl-list* 0 0 1 p2))))
- (while(setq i(+ i 1)e(ssname ss i))
- (setq pt(mapcar(function cons)
- (vl-sort(mapcar(function(lambda(x)(append(PToLn x p1 p2)x)))(startend e))
- (function(lambda(x y)(<(caddr x)(caddr y)))))pt)))
- (setq pt(mapcar(function(lambda(x fun)(mapcar(function cdddr)(vl-sort x(function(lambda(x y)(fun(car x)(car y))))))))pt(list < >)))
- (makepl(list(apply(function append)pt)1))))
;;;取选择集第一条线为基准线
;;;其它线求它们的起止点到基准线的投影,按投影后所在位置区分左右端点
;;;分别对左右端点表按到基准线的距离排序(左端点从小到大,右端点从大到小)
;;;用排序后的眼点集绘制闭合多段线 |