- (defun UnFormat (Mtext KeepLF / Text Str)
- (vl-load-com)
- (cond
- ((= (type Mtext) 'VLA-Object))
- ((= (type Mtext) 'ENAME)
- (setq Mtext (vlax-ename->vla-object Mtext))
- )
- (1 (setq Mtext nil))
- )
- (and
- Mtext
- (= (vlax-get Mtext 'ObjectName) "AcDbMText")
- (setq Mtext (vlax-get Mtext 'TextString))
- (setq Text "")
- (while (/= Mtext "")
- (cond
- ((wcmatch (strcase (setq Str (substr Mtext 1 2))) "\\[\\{}`~]")
- (setq Mtext (substr Mtext 3)
- Text (strcat Text Str)
- )
- )
- ((wcmatch (substr Mtext 1 1) "[{}]")
- (setq Mtext (substr Mtext 2))
- )
- ((and KeepLF (wcmatch (strcase (substr Mtext 1 2)) "\\P"))
- (setq Mtext (substr Mtext 3)
- Text (strcat Text "\\P")
- )
- )
- ((wcmatch (strcase (substr Mtext 1 2)) "\\[LOP]")
- (setq Mtext (substr Mtext 3))
- )
- ((wcmatch (strcase (substr Mtext 1 2)) "\\[ACFHQTW]")
- (setq Mtext (substr Mtext (+ 2 (vl-string-search ";" Mtext))))
- )
- ((wcmatch (strcase (substr Mtext 1 2)) "\\S")
- (setq Str (substr Mtext 3 (- (vl-string-search ";" Mtext) 2))
- Text (strcat Text (vl-string-translate "#^/" " " Str))
- Mtext (substr Mtext (+ 4 (strlen Str)))
- )
- )
- ((> (ascii Mtext) 127)
- (setq Text (strcat Text (substr Mtext 1 2))
- Mtext (substr Mtext 3)
- )
- )
- (1
- (setq Text (strcat Text (substr Mtext 1 1))
- Mtext (substr Mtext 2)
- )
- )
- )
- )
- )
- Text
- )
- ;;;以上自定义函数 unformat引自明经通道之咬文嚼字等一系列高人作品
- (defun c:gzt( / n ss e el)
- (setq ss (ssget))
- (setq n 0)
- (repeat (sslength ss)
- (setq e (ssname ss n))
- (setq el (entget e))
- (if (= "MTEXT" (cdr (assoc 0 el)))
- (progn
- (setq el (subst (cons 1 (strcat "{\\fSTZhongsong|b0|i0|c134|p2;" (unformat e keepfl) "}")) (assoc 1 el) el)) ;;;此处例举改为华文中宋
- (entmod el)
- )
- )
- (setq n (+ n 1))
- )
- (princ)
- )
- ;;;常用字体列表,其余可自己查询
- ;;;fSTZhongsong|b0|i0|c134|p2 华文中宋
- ;;;fSimHei|b0|i0|c134|p2 黑体
- ;;;fLiSu|b0|i0|c134|p49 隶书
- ;;;fFangSong_GB2312|b0|i0|c134|p49 仿宋2312
- ;;;fKaiTi_GB2312|b0|i0|c134|p49 楷体2312
- ;;;fNSimSun|b0|i0|c134|p49 新宋体
- ;;;fSimSun|b0|i0|c134|p2 宋体
为何这些字体必须原封不动的复制才能够替换成功,若照猫画虎逐字符输入则无任何反应呢?
|