Looking for a Lisp substitute all textstyles to a specific ttf

Looking for a Lisp substitute all textstyles to a specific ttf

Hans_Knol
Advocate Advocate
664 Views
3 Replies
Message 1 of 4

Looking for a Lisp substitute all textstyles to a specific ttf

Hans_Knol
Advocate
Advocate

Hi all,

 

I'm looking for a lisp routine that will be change all textstyles in the drawing sustitute from a shx to a ttf, for ex. changing it to Arial.ttf

 

Hope someone have a tool for this.

 

Hans

Hans Knol
0 Likes
Accepted solutions (2)
665 Views
3 Replies
Replies (3)
Message 2 of 4

dbroad
Mentor
Mentor
Accepted solution

Here is a sample. To use it, you should wrap it in a defun with a command name you select.  The values in the setfont method would depend on the font you want to use.  If using other than arial, use the style command to create the style and then use the getfont method to determine the appropriate setfont settings for automation. Read more about the setfont file in the activex help docs.

(vlax-for n (vla-get-textstyles
	      (vla-get-activedocument
		(vlax-get-acad-object)))
    (vla-setfont n "arial" :vlax-false :vlax-false 0 34)
    )

seect 

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 3 of 4

hak_vz
Advisor
Advisor
Accepted solution

Try this

 

 

(defun c:change_all_textstyle_font ( / newfont doc)
	(setq newfont (getstring T "\nEnter new font for all text styles >"))
	  (vlax-for style (vla-get-textstyles (setq doc (vla-get-activedocument (vlax-get-acad-object))))
		(vla-put-fontfile style newfont)
	  )
	(vla-regen doc acactiveviewport)
)

 

 

Font name: Arial.ttf   Times.ttf  Century.ttf  or look for file name in C:\windows\fonts by right click and properties

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

There's another topic [if not more than one] about this, which has different code to do the same thing, but also has a >suggestion you might want to consider<.

Kent Cooper, AIA
0 Likes