TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lonnie on April 29, 2020, 10:41:03 AM

Title: Global change of font styles
Post by: Lonnie 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
 
Title: Re: Global change of font styles
Post by: tombu on April 29, 2020, 10:45:09 AM
Merge text styles (or change text styles)
https://www.theswamp.org/index.php?topic=17659.0
Title: Re: Global change of font styles
Post by: ronjonp 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. )
Title: Re: Global change of font styles
Post by: Lonnie on April 29, 2020, 11:23:39 AM
Works at least in the first 4 dwg's.
Thank you.
Title: Re: Global change of font styles
Post by: ronjonp on April 29, 2020, 11:29:54 AM
Works at least in the first 4 dwg's.
Thank you.
You're welcome.  :-)