既然大家这么活跃,直接放源码:
【统一所有字体为宋体】
顺便也解决了乱码问题。保存图纸后也不再弹出提示换字体。
其实弹不弹提示,不是最烦的。
最烦的是乱码问号。各种设计院独立门户,滥用字体秀智商............
统一字体,避免张三李四的,字体一大堆,看起来极为不爽
- (defun c:HT (/ OBJNAME ATTS);原作者:liunian0524
- (vl-load-com)
- (setq ThisDrawing(vla-get-activedocument (vlax-get-acad-object)))
- (Setq TextStyles(vla-get-TextStyles ThisDrawing))
- (Setq TextStyle(vla-add TextStyles "仿宋"))
- (vla-SetFont TextStyle "仿宋" :vlax-false :vlax-false 1 0)
- (vlax-for blkobj (vla-get-blocks
- (vla-get-ActiveDocument (vlax-get-acad-object))
- )
- (vlax-for obj blkobj
- (if (or (= "AcDbMText" (setq objname (vla-get-objectname obj)))
- (= "AcDbText" objname)
- (= "AcDbAttribute" objname)
- (= "AcDbAttributeDefinition" objname)
- )
- (VL-CATCH-ALL-APPLY 'vla-put-stylename (list obj "仿宋"))
- )
- (if (and
- (or (= "AcDbMInsertBlock" objname)
- (= "AcDbBlockReference" objname)
- )
- (setq atts (vlax-invoke obj 'GetAttributes))
- )
- (foreach a atts (VL-CATCH-ALL-APPLY 'vla-put-stylename (list a "仿宋")))
- )
- )
- )
- (setvar 'textstyle "仿宋")
- (command "purge" "st" "*" "n")
- (princ)
- )
|