(defun c:mstretch(/ n ss ss2 a b lst lst2 lst3 lst4 flag p1 p2 p3 p4 zflag)(acet-error-init(list(list"cmdecho"0"highlight"0"dragmode"(getvar"dragmode")"osmode"0"cecolor""6""celtype""CONTINUOUS""limcheck"0)T '(progn(acet-temp-segment nil nil nil 1)(acet-sysvar-set(list"cmdecho"0))(command"_.redraw")(acet-sysvar-restore)(princ))))(sssetfirst nil nil)(princ"\n定义交叉窗口或交叉多边形...")(setvar"highlight"1)(setq ss(ssadd))(command"_.select")(while(not flag)(if(not lst)(progn(initget 128"CP C _CP C")(princ"\n选项: 交叉多边形(CP)或交叉第一点(C)")(setq a(getpoint"\n指定一个选项 [交叉多边形(CP)/交叉第一点(C)] <交叉第一点>: ")))(progn(initget 128"CP C Undo _CP C Undo")(princ"\n选项: 交叉多边形(CP)、交叉第一点(C)或放弃(U)")(setq a(getpoint"\n指定一个选项 [交叉多边形(CP)/交叉第一点(C)/放弃(U)] <交叉第一点>: "))))(cond((or(and(= a"C")(progn(initget 1)(setq a(getpoint"\n指定第一个角点: ")))(progn(initget 33)(setq b(getcorner a"\n指定其他角点: "))))(and a(equal(type a)'LIST)
(progn(initget 33)(setq b(getcorner a"\n指定其他角点: ")))))(setq lst(append lst(list(list a b)))lst4(append lst4(list(ssget"_c"a b)))p3(trans '(0.0 0.0 0.0)1 0)p4(trans(getvar"viewdir")1 0 T))(acet-lwpline-make(list(list(cons 210 p4))(acet-geom-rect-points(trans a 1 p4)(trans b 1 p4))))(command(entlast))(setq lst3(append lst3(list(entlast)))))((= a"CP")(progn(if(setq lst2(acet-ui-polygon-select 1))(progn(setq lst2(append lst2(list(car lst2)))lst(append lst(list lst2))lst4(append lst4(list(ssget"_cp"(cdr lst2))))p3(trans '(0.0 0.0 0.0)1 0)p4(trans(getvar"viewdir")1 0 T))(acet-lwpline-make(list(list(cons 210 p4))(acet-geom-m-trans lst2 1 p4)))(command(entlast))(setq lst3(append lst3(list(entlast))))))))((and lst(= a"Undo"))(command"_r"(last lst3)"_a")(if(acet-layer-locked(getvar"clayer"))(progn(command"")(command"_.layer""_unl"(getvar"clayer")"")(entdel(last lst3))(command"_.layer""_lock"(getvar"clayer")"")(command"_.select")(if(>(length lst3)1)(eval(append '(command)(cdr(reverse lst3))
))))(entdel(last lst3)))(setq lst3(reverse(cdr(reverse lst3)))lst4(reverse(cdr(reverse lst4)))lst(reverse(cdr(reverse lst)))))((or(= a"")(not a))(setq flag T))(T(princ"\n无效"))))(command"")(setvar"highlight"0)(if lst(progn(princ"\n完成定义拉伸窗口...")(if(acet-layer-locked(getvar"clayer"))(progn(command"_.layer""_unl"(getvar"clayer")"")(setq lst(reverse lst))(setq n 0)(repeat(length lst3)(entdel(nth n lst3))(setq n(+ n 1)))(command"_.layer""_lock"(getvar"clayer")""))(progn(setq lst(reverse lst))(setq n 0)(repeat(length lst3)(entdel(nth n lst3))(setq n(+ n 1)))))(setvar"highlight"1)(command"_.select")(repeat(length lst4)(if(car lst4)(command(car lst4)))(setq lst4(cdr lst4)))(command"")(setq ss(ssget"_p"))(if ss(progn(command"_.select"ss)(if(assoc"OSMODE"(car acet:sysvar-list))(setvar"osmode"(cadr(assoc"OSMODE"(car acet:sysvar-list)))))(setq p1 nil)(while(not p1)(initget 128"Remove _Remove")(setq p1(getpoint"\n指定一个选项 [删除对象(R)] <基点(B)>: "))
(if(not p1)(setq p1(car(acet-geom-view-points))))(if(and p1(not(equal p1"Remove"))(not(equal(type p1)'LIST)))(progn(setq p1 nil)(princ"\n无效输入。"))))(command"")(if(= p1"Remove")(progn(setvar"highlight"0)(acet-ss-clear-prev)(setvar"highlight"1)(command"_.select"ss"_r""_auto")(setvar"cmdecho"1)(while(wcmatch(getvar"cmdnames")"*SELECT*")(command pause))(if(setq ss2(ssget"_P"))(progn(command"_.select"ss2)(setq p1(getpoint"\n指定基点: "))(command"")(if(not p1)(setq p1(car(acet-geom-view-points)))))))(setq ss2 ss))(if ss2(progn(setq lst2 lst)(repeat(length lst2)(if(>(length(car lst2))2)(setq lst2(append(cdr lst2)(car lst2)))(setq lst2(cdr lst2))))(if(and(>(length(car lst))2)(acet-geom-zoom-for-select(car lst)))(progn(setvar"cmdecho"0)(command"_.select"ss2)(setq p2(getpoint p1"\n指定第二个基点: "))(command""))(progn(setvar"cmdecho"0)(command"_.stretch")(cp_loop(car lst))(command"_r"ss"_a"ss2""p1)(setvar"cmdecho"1)(princ"\n第二个基点: ")(command pause)(setvar"cmdecho"0)
(setq p2(getvar"lastpoint"))(setq lst(cdr lst))))(if(setq zflag(acet-geom-zoom-for-select lst2))(command"_.zoom""_w"(car zflag)(cadr zflag)))(setvar"highlight"0)(setvar"dragmode" 0)(setvar"osmode" 0)(setq n 0)(repeat(length lst)(setq a(nth n lst))(command"_.stretch")(cp_loop a)(command"_r"ss"_a"ss2""p1 p2)(setq n(+ n 1)))(if zflag(command"_.zoom""_p")))(princ"\n未选中任何对象")))(princ"\n未选中任何对象"))))(acet-error-restore)(princ))(defun cp_loop(lst / n)(if(equal(length lst)2)(command"_c"(car lst)(cadr lst))(progn(command"_cp")(setq n 0)(repeat(length lst)(command(nth n lst))(setq n(+ n 1)))(command""))))(princ)
