(defun ai_rtos(val / a b units old_dimzin)(setq units(getvar"lunits"))(if(or(= units 4)(= units 5))(rtos val)(progn(setq old_dimzin(getvar"dimzin"))(setvar"dimzin"(logand old_dimzin(~ 8)))(setq a(rtos val))(setvar"dimzin"(logior old_dimzin 8))(setq b(rtos val units 15))(setvar"dimzin"old_dimzin)(if(equal(distof a)(distof b)0.000001)a b))))(defun c:chspace(/ ss ss2 flag flag2 vp lim flt)(acet-error-init (list(list"highlight"0 "osmode"0"ucsfollow"0"insname"(getvar"insname")"limcheck"0)T '(progn (acet-table-purge"block""bns_chspace"nil))))(if(equal(getvar"pickfirst")1)(setq ss(cadr(ssgetfirst))))(sssetfirst nil nil)(setvar"highlight"1)(cond ((not(equal 0(getvar"tilemode")))(princ"\n** 在模型中命令不允许 **"))((and(not(equal(getvar"cvport")(car(setq flag(acet-viewport-next-pickable)))))(not(equal 1(getvar"cvport"))))(princ"\n  在透视视图中命令不会执行  "))((car flag)(progn(setq vp(getvar"cvport"))(if(and(or ss(setq ss(ssget)))(setq flt(list(list"LAYERUNLOCKED"))
ss(car(acet-ss-filter(list ss flt T))))(setq ss(ss_remove_viewports ss))(>(sslength ss)0))(progn(setvar"cvport"vp)(command"_.mspace")(if(and(setq ss2(ssget"_x"'((0 . "VIEWPORT")(67 . 1))))(=(sslength ss2)2))(setq flag2 T))(while(not flag2)(if(equal vp 1)(getstring"\n激活目标视口并按回车键继续。")(getstring"\n激活源视口并按回车键继续。"))(if(equal(getvar"cvport")(car(setq flag(acet-viewport-next-pickable))))(setq flag2 T)(progn(princ"\n*Invalid*")(princ(strcat"\n不能使用已关闭的"" 或有透视视图的视口。")))))(if(equal vp 1)(command"_.pspace"))(if(bns_check_for_f_vp ss)(progn(sssetfirst nil nil)(setvar"highlight"0)(chspace ss)))))))((and(not(car flag))(cadr flag))(princ(cadr flag))))(setq lim(getvar"limcheck"))(acet-error-restore)(if(/= lim(getvar"limcheck"))(setvar"limcheck"lim))(princ))(defun chspace(ss / msg ss2 na e1 n a b c d xd target)(acet-table-purge"block""bns_chspace"T)(if(not(equal(getvar"cvport")1))(progn(acet-ucs-cmd(list"_view"))(setq na(acet-currentviewport-ename)
e1(entget na '("ACAD"))xd(cdr(car(cdr(assoc -3 e1))))a(cdr(assoc 41 e1))b(getvar"viewsize")c(/ a b)d '(0.0 0.0 0.0))(acet-sysvar-set(list"limcheck"0))(sssetfirst nil nil)(command"_.block""bns_chspace"(trans d 0 1)ss"")(acet-sysvar-restore)(setq d(trans d 0 1))(setq d(trans d 1 2))(setq d(trans d 2 3))(acet-ucs-cmd(list"_p"))(command"_.pspace")(acet-ucs-cmd(list"_W"))(setq msg" MODEL space to PAPER space."))(progn (command"_.mspace")(acet-ucs-cmd(list"_view"))(setq na(acet-currentviewport-ename)e1(entget na '("ACAD"))xd(cdr(car(cdr(assoc -3 e1))))a(cdr(assoc 41 e1))b(getvar"viewsize")c(/ b a)d '(0.0 0.0 0.0)target(cdr(assoc 1010 xd)))(acet-ucs-cmd(list"_p"))(command"_.pspace")(acet-ucs-cmd(list"_w"))(setq d(trans d 0 1)d(trans d 1 2)d(trans d 2 3))(acet-sysvar-set(list"limcheck"0))(sssetfirst nil nil)(command"_.block""bns_chspace"d ss"")(acet-sysvar-restore)(acet-ucs-cmd(list"_p"))(command"_.mspace")(acet-ucs-cmd(list"_view"))(setq d '(0.0 0.0 0.0)d(trans d 0 1)d(acet-geom-vector-add d 
(trans target 0 1 T))msg" PAPER space to MODEL space.")))(setq na(entlast))(acet-sysvar-set(list"limcheck"0))(command"_.insert""*bns_chspace")(command d)(command c 0)(acet-sysvar-restore)(if(setq ss2(acet-ss-new na))(command"_.select"ss2""))(if(setq ss(ssget"_p"'((-4 . "<OR")(0 . "DIMENSION")(0 . "LEADER")(-4 . "OR>")) ))(progn(setq n 0)(repeat(sslength ss)(setq na(ssname ss n)e1(entget na '("ACAD"))a(cdr(car(cdr(assoc -3 e1))))b '(1070 . 40)d '(1070 . 144))(if(member b a)(setq b(* c(cdr(cadr(member b a)))))(setq b c))(if(member d a)(setq d(*(/ 1.0 c)(cdr(cadr(member d a)))))(setq d(/ 1.0 c)))(command"_.dimoverride""_dimscale"b "_dimlfac" d""na"")(setq n(+ n 1)))))(acet-table-purge"block""bns_chspace"nil)(command"_.select"ss2"")(acet-ucs-cmd(list"_p"))(princ(strcat"\n"(itoa(sslength ss2))" 个对象发生改变从 "msg))(princ(strcat"\n个对象缩放以比例 "(ai_rtos c)" 以保持可视效果。")))(defun ss_remove_viewports(ss / n j)(if(and ss(>(sslength ss)0))(progn(setq n(sslength ss))
(command"_.select"ss"")(setq ss(ssget"_p"'((-4 . "<NOT")(0 . "VIEWPORT")(-4 . "NOT>"))))(if(not ss)(setq j 0)(setq j(sslength ss)))(if(not(equal n j))(princ(strcat"\n忽略 "(itoa(- n j))" 个已选择的视口。")))))ss)(defun bns_check_for_f_vp(ss / ss2 na2 na e1 n a flag lst)(if(not(equal(getvar"cvport")1))(progn(command"_.pspace")(setq na2(acet-currentviewport-ename))(setq lst(acet-viewport-frozen-layer-list na2))(setq n 0)(while(< n(sslength ss))(setq na(ssname ss n)e1(entget na)a(cdr(assoc 8 e1)))(if(member a lst)(setq flag T))(setq n(+ n 1)))(command"_.mspace"))(progn (command"_.mspace")(setq na2(acet-currentviewport-ename))(setq lst(acet-viewport-frozen-layer-list na2))(setq n 0)(while(< n(sslength ss))(setq na(ssname ss n)e1(entget na)a(cdr(assoc 8 e1)))(if(member a lst)(setq flag T))(setq n(+ n 1)))(command"_.pspace")))(if flag(progn(princ(strcat"\n目标视口中有一个或更多  ""选定的对象在冻结的图层上。"))(initget"Yes No")(if(equal(getkword"\n仍然继续？ <是>: ")"No")(setq flag nil)
(setq flag T)))(setq flag T))flag)(princ)
