(defun c:tSpaceInvaders(/ flt ss ss2 ans lok)(acet-error-init (list(list"cmdecho"0 "ucsicon"0"osmode"0"ucsfollow"0)0 '(progn(if na(redraw na 4))(if(tblobjname"view""acet-tspaceinvaders")(progn(acet-sysvar-set(list"cmdecho"0))(command"_.view""_d""acet-tspaceinvaders")(acet-sysvar-restore))))))(setq flt '((-4 . "<OR")(0 . "ATTDEF")(0 . "TEXT")(0 . "MTEXT")(0 . "RTEXT")(-4 . "<AND")(0 . "INSERT")(66 . 1)(-4 . "AND>")(-4 . "OR>"))lok(acet-layer-unlock-all))(if(and(not(and(=(getvar"viewmode")1)(princ"\n** 命令在透视视图上不允许 **")))(setq ss(ssget flt))(setq ss(car(acet-ss-filter(list ss nil T))))(setq ss(acet-ss-annotation-filter ss)))(progn(if(setq ss2(acet-tspaceinvaders ss))(progn(princ(acet-str-format"\n%1 文字物体发现有重叠。"(sslength ss2)))(if(=(getvar"cmdnames")"")(progn(initget"Yes No")(setq ans(getkword"\n要一步眇的通过确认吗？ <否>: "))(if(="Yes"ans)(setq ss2(acet-tspaceinvaders-interact ss2))))))(princ"\n没有发现文字有重叠物体。"))))(if lok(command"_.-layer""_lock"lok""))
(acet-error-restore)(if ss2(progn(princ(acet-str-format"\n%1 物体被放置到当前选择集中。"(sslength ss2)))(sssetfirst ss2 ss2)))(princ))(defun acet-tspaceinvaders(ss / flt n na e1 lst lst2 ss2 ss3 j p1 p2 p3 getx)(if(tblobjname"view""acet-tspaceinvaders")(command"_.view""_d""acet-tspaceinvaders"))(command"_.view""_s""acet-tspaceinvaders")(defun getx(e1)(car(cdr(assoc 10 e1))))(setq ss(acet-ss-sort ss 'getx))(setq flt '((-4 . "<OR")(0 . "ATTDEF")(0 . "TEXT")(0 . "MTEXT")(0 . "RTEXT")(-4 . "<AND")(0 . "INSERT")(66 . 1)(-4 . "AND>")(-4 . "OR>"))ss3(ssadd))(acet-ui-progress-init"Searching for text with overlapping geometry..."(sslength ss))(setq n 0)(repeat(sslength ss)(setq na(ssname ss n)e1(entget na)lst(acet-geom-textbox e1 0.0))(acet-ui-progress-safe n)(if(and lst(not(equal(car lst)(cadr lst)))(not(equal(car lst)(caddr lst)))(not(equal(cadr lst)(caddr lst))))(progn(setq lst2(acet-geom-m-trans lst 1 0))(acet-ucs-cmd(list"_3p"(car lst)(cadr lst)(caddr lst)))
(setq lst2(acet-geom-m-trans lst2 0 1))(acet-tspaceinvaders-get-text-on-screen e1)(acet-ss-visible(ssadd na(ssadd))1)			(entupd na)(setq ss2(ssget"_c"(car lst2)(caddr lst2)))(acet-ss-visible(ssadd na(ssadd))0)			(entupd na))(setq ss2 nil))(if ss2(setq ss3(ssadd na ss3)))(acet-ucs-cmd(list"_p"))(setq n(+ n 1)))(acet-ui-progress-done)(command"_.view""_r""acet-tspaceinvaders")(command"_.view""_d""acet-tspaceinvaders")(if(=(sslength ss3)0)(setq ss3 nil))ss3)(defun acet-tspaceinvaders-interact(ss / na e1 lst n vpna ans p1 p2 p3 j)(if(tblobjname"view""acet-tspaceinvaders")(command"_.view""_d""acet-tspaceinvaders"))(command"_.view""_s""acet-tspaceinvaders")(setq vpna(acet-currentviewport-ename))(if(acet-viewport-is-perspective vpna)(princ"\n不能缩放透视视图中的物体。")(progn(acet-ui-progress-init"Searching for text with overlapping geometry..."(sslength ss))(setq j 0)(setq n 0)(while(< n(sslength ss))(acet-ui-progress-safe j)(setq j(+ j 1))(setq na(ssname ss n)e1(entget na)
lst(acet-geom-textbox e1 10.0)lst(acet-geom-list-extents lst)p1(car lst)p2(cadr lst)p3(acet-geom-midpoint p1 p2)p1(acet-geom-point-scale p1 p3 2.5)p2(acet-geom-point-scale p2 p3 2.5))(setq vpna(acet-currentviewport-ename))(if(acet-viewport-is-perspective vpna)(princ"\n不能缩放透视视图中的物体。")(progn(command"_.zoom"p1 p2)(redraw na 3)(acet-blink-and-show-object(list na 2))(initget"Yes No eXit")(setq ans(getkword"\n在选择集中包含这个吗？[退出(X)] <是>: "))(cond((= ans"No")(setq ss(ssdel na ss)n(- n 1)))((= ans"eXit")(setq n(sslength ss))))(redraw na 4)))(setq n(+ n 1)))(acet-ui-progress-done)))(command"_.view""_r""acet-tspaceinvaders")(command"_.view""_d""acet-tspaceinvaders")ss)(defun acet-tspaceinvaders-get-text-on-screen(e1 / lst h x a b)(setq lst(acet-geom-textbox e1 0.0)h(cdr(assoc 40 e1))x 0.01 )(if(or(acet-geom-zoom-for-select lst)(< h(* x(getvar"viewsize"))))(command"_.zoom""_c"(acet-geom-midpoint(car lst)(caddr lst))(max(* 1.1(distance(car lst)(caddr lst)))(*(/ 1.0 x)h)))))
(defun c:tscale(/ flt ss mode val base)(acet-error-init '(("cmdecho"0 "highlight"nil)1))(setq flt '((-4 . "<OR")(0 . "ATTDEF")(0 . "TEXT")(0 . "MTEXT")(0 . "RTEXT")(-4 . "<AND")(0 . "INSERT")(66 . 1)(-4 . "AND>")(-4 . "OR>")))(if(and(setq ss(ssget"_:L"flt))(setq ss(car(acet-ss-filter(list ss nil T))))(setq ss(acet-ss-annotation-filter ss)))(progn(setq base(acet-tscale-ui-get-scalebase)mode(acet-tscale-ui-get-mode))(if(= mode 0)(setq val(acet-tscale-ui-get-factor))(setq val(acet-tscale-ui-get-height)))(acet-tscale ss base mode val)))(acet-error-restore))(defun c:psTscale(/ flt ss mode h base na e1 n setmode vh xd vs val id)(acet-error-init '(("cmdecho"0 "highlight"nil)1))(setq id"ACET-PSTSCALE")(if(not(tblobjname"appid"id))(regapp id))(setq flt '((-4 . "<OR")(0 . "ATTDEF")(0 . "TEXT")(0 . "MTEXT")(0 . "RTEXT")(-4 . "<AND")(0 . "INSERT")(66 . 1)(-4 . "AND>")(-4 . "OR>")))(if(and(setq ss(ssget"_:L"flt))(setq ss(car(acet-ss-filter(list ss nil T))))(setq ss(acet-ss-annotation-filter ss)))
(progn(setq setmode(acet-pstscale-ui-get-mode))(if(= setmode 1)(progn(setq h(acet-pstscale-ui-get-height))(setq n 0)(repeat(sslength ss)(setq na(ssname ss n))(acet-ps-scale-set-xdata na h id)(setq n(+ n 1)))))(setq base(acet-tscale-ui-get-scalebase))(cond((=(getvar"tilemode")1)(princ"\n** 在模型中不允许更新 **"))((not(setq na(acet-currentviewport-ename)))(princ"\n不能取得当前视口。"))((acet-viewport-is-perspective na)(princ"\n** 在透视视图中不能执行更新 **"))(T(setq e1(entget na '("ACAD"))vs(cdr(assoc 41 e1))		 xd(cdr(assoc -3 e1))xd(cdr(assoc"ACAD"xd))xd(acet-list-m-assoc 1040 xd)vh(cdr(nth 1 xd))		 val(/ vh vs))(acet-tscale ss base 2 val)))))(acet-error-restore))(defun acet-viewport-is-perspective(na / e1 xd flag)(if na(setq e1(entget na '("ACAD"))  xd(cdr(assoc -3 e1))xd(cdr(assoc"ACAD"xd))  xd(cdr(member(assoc 1070 xd)xd))xd(cdr(assoc 1070 xd))flag(= 1(logand 1 xd))))flag)(defun acet-ps-scale-set-xdata(na scale appid / a e1 xd)(setq e1(entget na))(if(not(equal(type scale)'LIST))
(setq scale(list scale)))(foreach a scale(setq xd(cons(cons 1041 a)xd)))(setq xd(list -3(cons appid xd)))(setq e1(append e1(list xd)))(entmod e1))(defun acet-ps-scale-get-xdata(na appid / e1 xd)(setq appid(xstrcase appid)e1(entget na(list appid))xd(cdr(assoc -3 e1))xd(cdr(assoc appid xd))xd(mapcar 'cdr xd))xd)(defun acet-tscale(ss base mode val / na n j id)(setq id"ACET-PSTSCALE")(acet-ui-progress-init"Scaling text"(sslength ss))(setq j 0)(setq n 0)(repeat(sslength ss)(setq na(ssname ss n))(acet-ui-progress-safe n)(if(acet-tscale-ent na base mode val id)(setq j(+ j 1)))(setq n(+ n 1)))(acet-safe-command T T(list"_.move"ss"""0,0""0,0"))(acet-ui-progress-done)j)(defun acet-tscale-ent(na base mode val id / e1 e2 n h ss2 psh)(setq e1(entget na(list id)))(cond((= mode 0)				(setq h(cdr(assoc 40 e1))h(* h val)))((= mode 1)				(setq h val))((= mode 2)				(if(setq psh(car(acet-ps-scale-get-xdata na id)))(setq h(* psh val))(setq h(cdr(assoc 40 e1))))))(cond ((="Existing"base)
(setq e1(subst(cons 40 h)(assoc 40 e1)e1))(setq e2(entmod e1)))(T(setq ss2(ssadd na(ssadd)))(acet-tjust ss2 base)				(setq e2(entget na)e2(subst(cons 40 h)(assoc 40 e2)e2)	)(setq e2(entmod e2))(acet-tjust ss2(acet-tjust-keyword e1))		))e2)(defun acet-tscale-ui-get-scalebase(/ def ans id)(setq id"ACET-TSCALE-SCALEBASE"def(acet-getvar(list id)))(if(not def)(setq def"Existing"))(princ"\n指定用于缩放基点的对正方式...")(initget"Existing Start Center Middle Right TL TC TR ML MC MR BL BC BR")(setq ans(getkword(acet-str-format"\n[现有(E)/开始(S)/中心(C)/中间(M)/右(R)/左上(TL)/中上(TC)/右上(TR)/左中(ML)/正中(MC)/右中(MR)/左下(BL)/中下(BC)/右下(BR)] <%1>: "def)))(if ans(acet-setvar(list id ans 3))(setq ans def))ans)(defun acet-tscale-ui-get-mode(/ def ans id)(setq id"ACET-TSCALE-BYHEIGHT"def(acet-getvar(list id)))(if(not def)(setq def 0))(if(= def 0)(setq ans"Scale")(setq ans"Height"))(initget"Scale Height")(setq ans(getkword(acet-str-format"\n指定改变的大小[比例(S)/高度(H)] <%1>: "ans)))(if ans
(progn(if(= ans"Scale")(setq def 0)(setq def 1))(acet-setvar(list id def 3))))def)(defun acet-tscale-ui-get-factor(/ def ans id)(setq id"ACET-TSCALE-FACTOR"def(acet-getvar(list id)))(if(not def)(setq def 1.0))(initget 6)(setq ans(getdist(acet-str-format"\n缩放比例 <%1>: "(rtos def 2(getvar"luprec")))))(if ans(acet-setvar(list id ans 3))(setq ans def))ans)(defun acet-tscale-ui-get-height(/ def ans id)(setq id"ACET-TSCALE-HEIGHT"def(acet-getvar(list id)))(if(not def)(setq def(getvar"textsize")))(initget 6)(setq ans(getdist(acet-str-format"\n最终高度 <%1>: "def)))(if ans(acet-setvar(list id ans 3))(setq ans def))ans)(defun acet-pstscale-ui-get-mode(/ def ans id)(setq id"ACET-PSTSCALE-SET"def(acet-getvar(list id)))(if(not def)(setq def 1))(if(= def 1)(setq ans"Set")(setq ans"Update"))(initget"Set Update")(setq ans(getkword (acet-str-format"\n更新或设置图纸空间文字高度 [设置(S)/更新(U)] <%1>: "ans)))(if ans(progn(if(= ans"Set")(setq def 1)(setq def 0))(acet-setvar(list id def 2))))def)
(defun acet-pstscale-ui-get-height(/ def ans id)(setq id"ACET-PSTSCALE-HEIGHT"def(acet-getvar(list id)))(if(not def)(setq def(getvar"textsize")))(initget 6)(setq ans(getdist(acet-str-format"\n指定在图纸空间中希望的文字高度单位 <%1>: "def)))(if ans(acet-setvar(list id ans 3))(setq ans def))ans)(princ)
