Author Topic: Global change of font styles  (Read 2548 times)

0 Members and 1 Guest are viewing this topic.

Lonnie

  • Newt
  • Posts: 175
Global change of font styles
« on: April 29, 2020, 10:41:03 AM »
I am looking into making a set of tools to bring autocad files into revit. One of the first things is to change the text to arial. I've tried a few ways to do it but nothing seems to work. Here is the latest.

Code: [Select]
(defun c:csf (/ doc sty)
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq sty (vla-get-textstyles doc))
  (vlax-for s sty (vla-put-fontfile s "C:\\Windows\\Fonts\\arial.ttf"))
  (vlax-for w sty (vla-put-width w 1.0))
  (vla-regen doc acAllViewports)
  (princ)
)

My problem is when I run this the fonts change to the nearest arial not to arial.ttf. Most times it's Arial CYR but I've had it change to arial.shx even.

As always thanks.
Lonnie
 

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Global change of font styles
« Reply #1 on: April 29, 2020, 10:45:09 AM »
Merge text styles (or change text styles)
https://www.theswamp.org/index.php?topic=17659.0
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Global change of font styles
« Reply #2 on: April 29, 2020, 11:20:07 AM »
I am looking into making a set of tools to bring autocad files into revit. One of the first things is to change the text to arial. I've tried a few ways to do it but nothing seems to work. Here is the latest.

Code: [Select]
(defun c:csf (/ doc sty)
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq sty (vla-get-textstyles doc))
  (vlax-for s sty (vla-put-fontfile s "C:\\Windows\\Fonts\\arial.ttf"))
  (vlax-for w sty (vla-put-width w 1.0))
  (vla-regen doc acAllViewports)
  (princ)
)

My problem is when I run this the fonts change to the nearest arial not to arial.ttf. Most times it's Arial CYR but I've had it change to arial.shx even.

As always thanks.
Lonnie
Try this mod .. I ran into this a while back too.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:csf (/ f doc)
  2.   (if (findfile (setq f (strcat (getenv "windir") "\\Fonts\\Arial.ttf")))
  3.     (progn
  4.         (vla-put-fontfile s f)
  5.         (vla-put-width s 1.0)
  6.         ;; RJP » 2020-04-29
  7.         (vla-setfont s "Arial" :vlax-false :vlax-false 0 34)
  8.       )
  9.       (vla-regen doc acallviewports)
  10.     )
  11.   )
  12.   (princ)
  13. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lonnie

  • Newt
  • Posts: 175
Re: Global change of font styles
« Reply #3 on: April 29, 2020, 11:23:39 AM »
Works at least in the first 4 dwg's.
Thank you.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Global change of font styles
« Reply #4 on: April 29, 2020, 11:29:54 AM »
Works at least in the first 4 dwg's.
Thank you.
You're welcome.  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC