本帖最后由 llsheng_73 于 2015-3-3 17:57 编辑
- (defun SstoEs(ss / a en lst)
- (if ss(repeat(setq a(sslength ss))
- (setq a(1- a)lst(cons(ssname ss a)lst))))
- lst)
- (defun plinexy(e / p i)
- (setq i -1)
- (mapcar(function(lambda(x)(list(car x)(cadr x))))(reverse(repeat(fix(1+(vlax-curve-getEndParam e)))
- (setq i(1+ i)p(cons(vlax-curve-getPointAtParam e i)p)))))
- (if(equal(car p)(last p))(reverse(cdr(reverse p)))p)
- )
- (defun ABCOfRectangle(e / pt a b);;矩形中心及长宽
- (if(and(=(length(setq pt(plinexy e)))4)
- (equal(setq a(distance(car pt)(cadr pt)))
- (distance(last pt)(caddr pt))1e-6)
- (equal(setq b(distance(cadr pt)(caddr pt)))
- (distance(last pt)(car pt))1e-6)
- (equal(distance(car pt)(caddr pt))
- (distance(last pt)(cadr pt))1e-6))
- (list(mapcar'(lambda(x)(* x 0.5))(mapcar'+(car pt)(caddr pt)))(vl-sort(mapcar'atof(mapcar'rtos(list a b)))'>))))
- (defun subtotals(lst m ns / myfun a b c);;对lst以子表第m项为关键字进行分类,ns为整数时记录第ns项、为表(2 3)记录表中指定的项、为空或者其它记录关键字以外所有项
- (cond((=(type ns)'LIST)(defun myfun(x)(list(mapcar'(lambda(y)(nth y x))ns))))
- ((=(type ns)'INT)(defun myfun(x)(list(nth ns x))))
- (t(defun myfun(x)(list(vl-remove c x)))))
- (foreach x lst
- (setq a(if(setq c(nth m x)b(assoc c a))
- (subst(append b(myfun x))b a)
- (append a(list(append(list c)(myfun x))))))))
- (defun maketxt(argments / InsOrDel);;argments pt txt la style color h hz jz z ro) txt后边的图层,字体可省
- (defun InsOrDel(lst pos mod / qlst a hlst);{在指定位置删除或插入元素mod为要插入的元素为空时删除第pos项}
- (setq a -1)
- (setq hlst(vl-member-if-not'(lambda(x)(setq a(1+ a))(if(= a pos) nil(setq qlst (cons x qlst))))lst))
- (if mod(apply 'append (list (reverse(cons mod qlst)) hlst))
- (apply 'append (list (reverse qlst)(cdr hlst)))))
- (setq argments(if(or(/=(type(nth 2 argments))'str)(null(tblsearch"layer"(nth 2 argments))))
- (InsOrDel argments 2(getvar'clayer))argments)
- argments(if(or(/=(type(nth 3 argments))'str)(null(tblsearch"style"(nth 3 argments))))
- (InsOrDel argments 3"Standard"))argments)
- (entmakex(mapcar'cons'(0 10 11 1 8 7 62 40 41 72 73 50)(append(list"TEXT"(car argments))argments))))
- (defun c:tt(/ ss i a)
- (if(setq ss(SstoEs(ssget'((0 . "*polyline")(90 . 4)(-4 . "<OR") (70 . 1)(70 . 129)(-4 . "OR>")))))
- (foreach x(subtotals(vl-remove'nil(mapcar'ABcOfRectangle ss))1 0)
- (setq i 0 a(strcat(rtos(caar x))"X"(rtos(cadar x))))
- (foreach y(cdr x)
- (maketxt(list y(strcat a"-"(itoa(setq i(1+ i))))1 1.5 1.0 1 2)))))
- )
凑热闹 |