本帖最后由 llsheng_73 于 2014-6-11 21:45 编辑
- (defun c:EX(/ dcl ctl getvalue lys l)
- (defun getvalue()
- (list(CAR(MEMBER(nth(atoi(get_tile"LA"))LYS)(STB"LAYER")))
- (if(atof(get_tile"JL"))(atof(get_tile"JL"))0.5)
- (IF(=(get_tile"ALL")"1")"1""2")))
- (setq dcl(makedcl'"ZDEX:dialog{label=\"~多线段自动延伸~\";:column{:row{:edit_box{label=\"限定距离\";key=\"JL\";edit_width=3;}:popup_list{label=\"图层\";key=\"LA\";}}:row{key=\"GET\";:radio_button{label=\"自动\";key=\"ALL\";value=\"1\";}:radio_button{label=\"选择\";key=\"MANU\";}:button{key=\"ESC\";label=\"取消\";is_cancel=true;}:button{key=\"GO\";label=\"确定\";}}}}")
- LYS(CONS"所有图层"(STB"LAYER"))ctl 3)
- (while(> ctl 2)(new_dialog"ZDEX"dcl)
- (start_list"LA")(mapcar'add_list LYS)(end_list)
- (set_tile"JL""0.5")
- (action_tile"GO""(setq l(getvalue))(done_dialog 1)")
- (action_tile"ESC""(done_dialog 0)")
- (setq ctl (start_dialog))
- )(unload_dialog dcl)
- (cond((= ctl 1)(layon)(ex(car l)(cadr l)(last l))(layreset)))
- (princ))
- (defun layon();图层全开、解锁、解冻
- (foreach x(setq *layststatus(mapcar'(lambda(x)(entget(TBLOBJNAME"layer"x)))(stb"layer")))
- (entmod(subst(cons 62(abs(cdr(assoc 62 x))))(assoc 62 x)(subst'(70 . 0)(assoc 70 x)x)))))
- (defun layreset();;恢复图层
- (foreach x *layststatus(entmod x))
- (setq *layststatus nil))
- (Defun STB(TAB / snl sll)
- (SetQ sll(TblNext TAB T))
- (While(SetQ snl(Cons(Cdr(Assoc 2 sll))snl)sll(TblNext TAB nil)))
- (vl-sort snl'<))
- (defun makedcl(str / dclfile dclHandle)
- (setq dclfile(vl-filename-mktemp nil nil ".dcl")dclHandle(open dclfile "w"))
- (write-line str dclHandle)
- (close dclHandle)
- (setq dclHandle(load_dialog dclfile))
- (vl-file-delete dclfile)
- dclHandle)
- (defun array->list(l / i p)
- (if(>(vlax-safearray-get-u-bound l 1)1)
- (progn
- (setq l(vlax-safearray->list l)i -3)
- (repeat(/(length l)3)
- (setq i(+ 3 i)p(cons(list(nth i l)(nth(+ 1 i)l))p))))))
- (defun SstoEs(ss / a en lst)
- (if ss(progn(setq a -1)
- (while(setq en(ssname ss(setq a(1+ a))))
- (setq lst(cons en lst)))))
- lst)
- (defun ex(la jl fs / ss a b c d);;fs"1"全选择"2"手动选择
- (setq a(if(null la)'((0 . "*lyline"))(list'(0 . "*lyline")(cons 8 la)))
- ss(sstoes(if(="1"fs)(ssget"X" a)(ssget a))))
- (foreach a ss
- (setq s1(vl-remove a ss)a(vlax-ename->vla-object a))
- (foreach b s1
- (setq b(vlax-ename->vla-object b)
- d(xlst(array->list(vlax-variant-value(vla-IntersectWith a b 0)))(array->list(vlax-variant-value(vla-IntersectWith a b 1)))))
- (foreach c d
- (if(<(distance(setq b(reverse(cdr(reverse(vlax-curve-getClosestPointTo a c 0)))))c)jl)
- (entmod(subst(cons 10 c)(cons 10 b)(entget(vlax-vla-object->ename a))))))
- )))
只适合多线段,因为别的线我很少涉及到,所以没弄它 |