明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3949|回复: 4

[讨论] Mtext多行文字字体修改

[复制链接]
发表于 2013-8-13 20:31 | 显示全部楼层 |阅读模式
  1. (defun UnFormat (Mtext KeepLF / Text Str)
  2.   (vl-load-com)
  3.   (cond
  4.     ((= (type Mtext) 'VLA-Object))
  5.     ((= (type Mtext) 'ENAME)
  6.       (setq Mtext (vlax-ename->vla-object Mtext))
  7.     )
  8.     (1 (setq Mtext nil))
  9.   )
  10.   (and
  11.     Mtext
  12.     (= (vlax-get Mtext 'ObjectName) "AcDbMText")
  13.     (setq Mtext (vlax-get Mtext 'TextString))
  14.     (setq Text "")
  15.     (while (/= Mtext "")
  16.       (cond
  17.         ((wcmatch (strcase (setq Str (substr Mtext 1 2))) "\\[\\{}`~]")
  18.           (setq Mtext (substr Mtext 3)
  19.                 Text   (strcat Text Str)
  20.           )
  21.         )
  22.         ((wcmatch (substr Mtext 1 1) "[{}]")
  23.           (setq Mtext (substr Mtext 2))
  24.         )
  25.         ((and KeepLF (wcmatch (strcase (substr Mtext 1 2)) "\\P"))
  26.           (setq Mtext (substr Mtext 3)
  27.                 Text  (strcat Text "\\P")
  28.           )
  29.         )
  30.         ((wcmatch (strcase (substr Mtext 1 2)) "\\[LOP]")
  31.           (setq Mtext (substr Mtext 3))
  32.         )
  33.         ((wcmatch (strcase (substr Mtext 1 2)) "\\[ACFHQTW]")
  34.           (setq Mtext (substr Mtext (+ 2 (vl-string-search ";" Mtext))))
  35.         )
  36.         ((wcmatch (strcase (substr Mtext 1 2)) "\\S")
  37.           (setq Str   (substr Mtext 3 (- (vl-string-search ";" Mtext) 2))
  38.                 Text  (strcat Text (vl-string-translate "#^/" "   " Str))
  39.                 Mtext (substr Mtext (+ 4 (strlen Str)))
  40.           )
  41.         )
  42. ((> (ascii Mtext) 127)
  43.   (setq Text (strcat Text (substr Mtext 1 2))
  44.         Mtext (substr Mtext 3)
  45.         )
  46.   )
  47.         (1
  48.           (setq Text (strcat Text (substr Mtext 1 1))
  49.                 Mtext (substr Mtext 2)
  50.           )
  51.         )
  52.       )
  53.     )
  54.   )
  55.   Text
  56. )
  57. ;;;以上自定义函数 unformat引自明经通道之咬文嚼字等一系列高人作品
  58. (defun c:gzt( / n ss e el)
  59.   (setq ss (ssget))
  60.   (setq n 0)
  61.   (repeat (sslength ss)
  62.     (setq e (ssname ss n))
  63.     (setq el (entget e))
  64.     (if (= "MTEXT" (cdr (assoc 0 el)))
  65.       (progn
  66.   (setq el (subst (cons 1 (strcat "{\\fSTZhongsong|b0|i0|c134|p2;" (unformat e keepfl) "}")) (assoc 1 el) el))     ;;;此处例举改为华文中宋
  67.   (entmod el)
  68.   )
  69.      )
  70.     (setq n (+ n 1))
  71.    )
  72.   (princ)
  73.   )

  74. ;;;常用字体列表,其余可自己查询
  75. ;;;fSTZhongsong|b0|i0|c134|p2               华文中宋
  76. ;;;fSimHei|b0|i0|c134|p2                    黑体
  77. ;;;fLiSu|b0|i0|c134|p49                     隶书
  78. ;;;fFangSong_GB2312|b0|i0|c134|p49          仿宋2312
  79. ;;;fKaiTi_GB2312|b0|i0|c134|p49             楷体2312
  80. ;;;fNSimSun|b0|i0|c134|p49                  新宋体
  81. ;;;fSimSun|b0|i0|c134|p2                    宋体
为何这些字体必须原封不动的复制才能够替换成功,若照猫画虎逐字符输入则无任何反应呢?
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2013-8-13 23:51 | 显示全部楼层
非常有用,解决了困扰几天的问题。。
不过解答不了你提的问题,等待高人。。
 楼主| 发表于 2013-8-14 08:15 | 显示全部楼层
梦里水香 发表于 2013-8-13 23:51
非常有用,解决了困扰几天的问题。。
不过解答不了你提的问题,等待高人。。

能给您些许帮助,是在下的荣幸。
唉,高端问题还是等高端人士赐教吧,期待中。。。
发表于 2013-8-14 08:31 | 显示全部楼层
这个程序不支持标注,不知道有没有高人能修改一下。
 楼主| 发表于 2013-8-14 18:01 | 显示全部楼层
梦里水香 发表于 2013-8-14 08:31
这个程序不支持标注,不知道有没有高人能修改一下。

什么标注?坐标的还可以研究下,要是尺寸的就没啥思路了。我也是低手,水平有限啊大哥。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-20 08:58 , Processed in 0.239940 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表