明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2852|回复: 7

[灌水]你的文字样式有问题?这个小程序帮你解决。

[复制链接]
发表于 2007-12-26 15:53:00 | 显示全部楼层 |阅读模式

参考网友程序进行修改而成

(defun c:chtxsy ( / a b1 b2 e f index n ns zt)
    (setvar "cmdecho" 0)
    (command "purge" "a" "*" "n")
    (setq A (ssget "x" '((0 . "TEXT,MTEXT"))))
           (if (tblsearch "style" "XIAOLIN")
        (princ)
                 (command "-style" "XIAOLIN" "txt.shx,hztxt.shx" "" "0.7" "" "" "" "")
               )
       (setvar "dimtxsty" "standard")
       (princ "正在处理中.....\n")
    (setq ns "XIAOLIN")
    (setq n (sslength a))
    (setq index 0)
    (repeat n
       (setq b1 (entget(ssname a index)))
       (setq index (+ index 1))
       (setq e (assoc 7 b1))
       (setq f (cons (car e) ns))
       (setq b2 (subst f e b1))
       (entmod b2)
       )
(command "-style" "hztxt" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "chian" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "dim_font" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "1" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "ht" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "hz" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "romand" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "standard" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "yy" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "ro" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "style1" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "-黑体" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "simplex" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "h1" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "youyuan" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "hz" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "kt64f" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "lushu" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "kaiti" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "meihei" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "songti" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "zongyi" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "宋体" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_simplex" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "att" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "dim" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "黑体" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "楷体" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "幼圆" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "华文" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "style2" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "style3" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "华文中宋" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "2" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "3" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "text" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "text1" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "text2" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "dim" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "dim1" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "dim2" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_ht64f" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_hzls" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_txt" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "1" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "2" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "3" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "4" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "5" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "6" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "ht" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_hzdx" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_cibt____" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "comb" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "middle" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_fds" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_romanc" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "cg" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "fs1" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_fs1" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "std" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_fsj" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "fs" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "st" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "LP1" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "ROMANT" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "lp2" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_HZTXT" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "_COMPLEX" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "-style" "complex" "txt.shx,hztxt.shx" "" "" "" "" "" "")
(command "purge" "a" "*" "n")
(princ "\n 字体转换成功!")
(setvar "cmdecho" 1)
(princ )
  )

;以方便各位解决字体问题。

发表于 2008-1-1 12:02:00 | 显示全部楼层

这样更简单

更换所有文字字体

(defun C:zas ()
   (graphscr)
   (initget 7)
   ;(setq c1 (getstring "\nInput new color for all layers: "))   ;输入新颜色
   (setq a1 (tblnext "style" t))                     ;将指针移到第一个字体
   ;  (princ a1)
  ;(setq a2 (cdr (assoc 2 a1)))                       ;取出图层名称
    ;  (setq a3 (entget (tblobjname "style" a2)))         ;取出图层的数据串行
    ;  (princ "  a3= ")(princ a3)
  (while a1
      (setq a2 (cdr (assoc 2 a1)))                       ;取出字体名称
      (setq a3 (entget (tblobjname "style" a2)))         ;取出字体的数据串行
      ;(princ a3)(princ "   ")
    (setq a3 (subst (cons 3 "txt_0.shx") (assoc 3 a3) a3))    ;将字体字型改成新字型
      (entmod a3)
                                       ;更新字体
    (setq a3 (subst (cons 4 "hzfs.shx") (assoc 4 a3) a3))    ;将字体字型改成新字型
      (entmod a3) 
    (setq a1 (tblnext "style"))                           ;找出下一个字体
   )
  (command"REGEN" "")
  (princ"字型变更成功!" )
   (princ)
)

发表于 2012-1-2 21:37:12 | 显示全部楼层
直接更改很方便

;;;改所有字体为: rs,hztxt
(defun c:rshz (/ a3 ss j n ed)
  (print "程序正在执行中,请稍后......")
  (command "style" "hz" "rs.shx,hztxt.shx" "" "" "" "")
  (setq a3 "hz")
  (setq ss (ssget "x" (list (cons 0 "text"))))
  (setq n (sslength ss))
  (setq j 0)
  (while (< j n)
     (setq ed (ssname ss j))
     (command "change" ed "" "" "" a3 "" "" "")
     (setq j (+ j 1))
   )
)
发表于 2012-1-2 22:44:13 | 显示全部楼层
谢谢!学习了
发表于 2012-1-4 11:49:23 | 显示全部楼层
不知道能不能更换多行文字字体哦,要是能够设置选择哪些字体更换成另外的字体就好了
发表于 2012-5-18 19:23:53 | 显示全部楼层
谢谢各位,太好了
发表于 2012-5-18 19:42:07 | 显示全部楼层
学习了,好贴子要顶起来
发表于 2012-5-19 02:44:27 | 显示全部楼层
这种没有效率的搞法,让人昏!我有一次性将所有字型改为同一字体程序,我编制的,需要请联系
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-7-22 05:13 , Processed in 0.175512 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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