马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
1、选择文字处理版本
![](source/plugin/imc_colorcode/images/loading.gif) - (defun c:XDTB_TXTD2SBC (/ ss x txt y second)
- (if (and (xdrx_initssget "选取要全角转半角的文字<退出>:")
- (setq ss (xdrx_ssget '((0 . "TEXT,MTEXT"))))
- )
- (progn
- (xdrx_begin)
- (mapcar
- '(lambda (x)
- (setq txt (xdrx_getpropertyvalue x "textstring"))
- (mapcar '(lambda (y)
- (if (= y " ")
- (setq txt (xdrx_string_regexpr " " txt " " 14))
- (progn
- (setq first (substr y 1 1)
- second (ascii (substr y 2 1))
- second (- second 128)
- str (chr second)
- )
- (setq txt (xdrx_string_regexpr y txt str 14))
- )
- )
- )
- (xdrx_string_regexps "[\\u3000\\uff01-\\uff5f]" txt)
- )
- (xdrx_setpropertyvalue x "textstring" txt)
- )
- (xdrx_pickset->ents ss)
- )
- (xdrx_end)
- )
- )
- (princ)
- )
下面是不打开DWG,批量处理的。
2、批量处理DWG版本
![](source/plugin/imc_colorcode/images/loading.gif) - (defun c:XDTB_TxtBatD2SBC (/ txt match n num fns dwg layous lay num1)
- (defun _replace (o)
- (setq txt (vla-get-textstring o))
- (if (setq
- match (xd::string:regexps "[\\u3000\\uff01-\\uff5f]" txt "")
- )
- (progn (foreach n match
- (if (= n " ")
- (setq txt (xd::string:regexpr " " txt " " ""))
- (progn (setq first (substr n 1 1)
- second (ascii (substr n 2 1))
- second (- second 128)
- str (chr second)
- )
- (setq txt (xd::string:regexpr n txt str ""))
- )
- )
- )
- (vla-put-textstring o txt)
- (setq num (1+ num)
- num1 (1+ num1)
- )
- )
- )
- )
- (defun _find_and_replace (doc)
- (textpage)
- (setq fns (1+ fns))
- (setq dwg (vla-get-name doc)
- dwg (strcat (vl-filename-base dwg) (vl-filename-extension dwg)))
- (princ (XD::String:TailFill (strcat "\n搜索 " dwg) " " 50))
- (setq layouts (vla-get-layouts doc))
- (setq num1 0)
- (vlax-for lay layouts
- (setq blk (vla-get-block lay))
- (vlax-for o blk
- (if (or (= (vla-get-objectname o) "AcDbText")
- (= (vla-get-objectname o) "AcDbMText")
- )
- (progn (_replace o))
- )
- )
- )
- (princ (strcat " 替换 " (itoa num1) " 个文字对象."))
- )
- (setq fns 0
- num 0
- )
- (xd::vla:odbx '_find_and_replace nil t)
- (princ (strcat "\n总共搜索了 "
- (itoa fns)
- " 个DWG文件,供转码了 "
- (itoa num)
- " 个文本对象."
- )
- )
- (princ)
- )
|