本帖最后由 llsheng_73 于 2015-8-30 04:24 编辑
- (DEFUN C:TT(/ lys d c d e)
- (if(setq d(setlys)lys(cdr d))
- (progn
- (command"undo""be")
- (setvar'cmdecho 0)
- (setq d(cons 40(/(car d)2.)))
- (foreach a(intersof(ssget(list'(0 . "line,arc,lwpolyline")(cons 8(apply'strcat(mapcar'(lambda(x)(strcat","x))lys)))))lys)
- (foreach b(setq c(car a)a(vl-sort(cdr a)'(lambda(x y)(>(vlax-curve-getDistAtPoint c x)(vlax-curve-getDistAtPoint c y)))))
- (command"trim"(setq e(entmakex(list'(0 . "circle")(cons 10 b)d)))""(list c b)"")
- (entdel e)))
- (setvar'cmdecho 1)
- (command"undo""end")))
- )
- (defun makedcl (str_lst / dclfile fileID dclHandle)
- (setq dclfile(vl-filename-mktemp nil nil ".dcl")fileID(open dclfile "w"))
- (cond((= (type str_lst) 'str)(write-line str_lst fileID))
- ((= (type str_lst) 'list)(foreach n str_lst (write-line n fileID))))
- (close fileID)
- (setq dclHandle (load_dialog dclfile))
- (vl-file-delete dclfile)
- dclHandle)
- (defun setlys(/ lys dcl setlys_move setlys_dl setlys_rd lays a l);;;by llsheng_73
- (Defun lays(/ snl sll)
- (SetQ sll (TblNext "layer" T))
- (While (SetQ snl (Cons (Cdr (Assoc 2 sll)) snl)sll (TblNext "layer" nil)))
- (vl-sort snl '<))
- (defun setlys_move(f);;;by llsheng_73
- (setq a(read(strcat "("(get_tile"LYS")")"))l(mapcar'(lambda(x)(nth x lys))a)
- lys(if f(append(setq a(append(reverse(cddr(member(car l)(reverse lys))))l))(vl-remove-if'(lambda(x)(member x a))lys))
- (append(setq a(append(vl-remove-if'(lambda(x)(member x l))(reverse(member(last l)(reverse lys))))
- (vl-remove'nil(cons(cadr(member(last l)lys))l))))(vl-remove-if'(lambda(x)(member x a))lys))))
- (start_list"LYS")(mapcar'add_list lys)(end_list)
- (set_tile"LYS"(setq a(mapcar'(lambda(x)(itoa(vl-position x lys)))l)
- a(strcat(car a)(apply'strcat(mapcar'(lambda(x)(strcat" "x))(cdr a)))))))
- (defun setlys_dl()
- (start_list"LYS")(mapcar'add_list(setq a(read(strcat "("(get_tile"LYS")")"))
- l(mapcar'(lambda(x)(nth x lys))a)
- lys(vl-remove-if'(lambda(x)(member x l))lys)))(end_list))
- (defun setlys_rd()
- (setq d(vlax-ldata-get"myset""layers")
- lys(if d(cdr d)(lays))d(if d(car d)200))
- (set_tile"IN"(rtos d))
- (start_list"LYS")(mapcar'add_list LYS)(end_list))
- (setq dcl(makedcl'("SETLYS:dialog{label=\"设置图层顺序\";:edit_box{key=\"IN\";label=\"修剪距离\";}"
- ":row{:list_box{key=\"LYS\";multiple_select=true;}"
- ":column{:button{key=\"UP\";label=\"上移\";}:button{key=\"DN\";label=\"下移\";}"
- ":button{key=\"DL\";label=\"移除\";}:button{key=\"RD\";label=\"重置\";} "
- "spacer;:button{key=\"GO\";label=\"确定\";is_default=true;}"
- ":button{key=\"ESC\";label=\"取消\";is_cancel=true;}}}}")))
- (new_dialog"SETLYS"dcl)
- (setlys_rd)
- (action_tile"UP""(setlys_move t)")
- (action_tile"DN""(setlys_move nil)")
- (action_tile"DL""(setlys_dl)")
- (action_tile"RD""(setlys_rd)")
- (action_tile"IN""(if(or(not(setq d(distof $value)))(<= d 0))(progn(alert\"修剪距离应该大于0\")(mode_tile\"IN\"2)))")
- (action_tile"GO""(done_dialog 1)")
- (if(=(start_dialog)1)(vlax-ldata-put"myset""layers"(cons d lys))))
- (defun subtotal(lst m ns / myfun a b c);;;by llslheng_73
- (defun myfun(x)(list(nth ns 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 intersof(ss lys / a b c d e i pts);;;by llslheng_73
- (setq i 0)
- (repeat(1-(sslength ss))
- (repeat(sslength(setq i -1 a(ssname ss 0)d(cdr(assoc 8(entget a)))ss(ssdel a ss)))
- (if(and(setq i(1+ i) b(ssname ss i) e(cdr(assoc 8(entget b)))
- c(if(/= e d)(apply'vla-IntersectWith(append(mapcar'vlax-ename->vla-object(list a b))'(0)))))
- (>(vlax-safearray-get-u-bound(setq c(vlax-variant-value c))1) 0))
- (setq pts(cons(list(vlax-safearray->list c)
- (caar(vl-sort(list(list a d)(list b e))'(lambda(x y)(>(vl-position(last x)lys)(vl-position(last y)lys))))))pts)))))
- (subtotal pts 1 0))
- (alert"依图层交点修剪,命令TT\n更多需求QQ275988734")
郁闷死了,上传不了图片也传不了附件,该死的IE11?
命令tt,用测试图测试没发现问题,可以调整图层顺序(但不是楼主要求的点选图元来决定顺序而是直接在对话框里边调整图层名列表的顺序)及定义剪切距离(要求大于0),这些数据会随图形一起保存,重新运行命令或者下次打开图形运行命令都会重新读取出来 |