Change All font in Text Style Manager

Change All font in Text Style Manager

Anonymous
Not applicable
10,135 Views
17 Replies
Message 1 of 18

Change All font in Text Style Manager

Anonymous
Not applicable

Hallo,

 

I have received some files which have numerous style created in text style manager. and it have "txt.shx" as font. But I need to change all this to Arial. Is there any lisp command to do this?. 

 

Thanks

 

Shameem

 

0 Likes
Accepted solutions (2)
10,136 Views
17 Replies
Replies (17)
Message 2 of 18

Anonymous
Not applicable
Accepted solution

 

Try This..

(while (setq st (tblnext "STYLE" (not st)))
       (setq st (entget(tblobjname "STYLE" (cdr(assoc 2 st)))))
       (entmod (subst '(3 . "Arial")(assoc 3 st) st))
)
Message 3 of 18

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

....But I need to change all this to Arial. Is there any lisp command to do this?. 

 

Thanks

 

Shameem

 


If you're going to do that, You might as well use one teststyle for all your text/mtext/attributes. 

 

Anyways

 

(setq ArialFont (strcat (getenv "systemroot") "\\Fonts\\Arial.ttf"))

(vlax-for DwgTextSTyle (vla-get-textstyles  (vla-get-ActiveDocument (vlax-get-acad-object)))
	
      	(and    (vlax-write-enabled-p DwgTextSTyle)
            	(vlax-property-available-p DwgTextSTyle 'Fontfile)
            	(vlax-put DwgTextSTyle 'Fontfile ArialFont)
                      )
      )

HTH

Message 4 of 18

Kent1Cooper
Consultant
Consultant

If there are differences in things like width factor or obliquing angle or other possibilities between different Styles, others' suggestions look appropriate.  But if they're all the same in appearance, there's no point in having lots of them, so another thing you could do would be to assign Arial to the "Standard" Style, change all Text/Mtext objects to Standard, and assign it to all Dimension Styles.  It could well be fewer steps than going through all Styles and changing the font assigned to each.  Then you can PURGE all those numerous Styles from the drawing.  That could also be written into an AutoLisp routine, if that sounds like a good approach.

Kent Cooper, AIA
0 Likes
Message 5 of 18

devitg
Advisor
Advisor

Hi Kent. please How could to assign Arial to the "Standard" Style, by lisp.

Thanks

 

 

 

0 Likes
Message 6 of 18

pbejse
Mentor
Mentor

 

(setq ArialFont (strcat (getenv "systemroot") "\\Fonts\\Arial.ttf"))

      (and
            (setq StandardTextSTyle
                       (vla-item (vla-get-textstyles  adoc) "Standard"))
      	    (vlax-write-enabled-p StandardTextSTyle)
            (vlax-property-available-p StandardTextSTyle 'Fontfile)
            (vlax-put StandardTextSTyle 'Fontfile ArialFont)
                      )
Message 7 of 18

Kent1Cooper
Consultant
Consultant

@devitg wrote:

Hi Kent. please How could to assign Arial to the "Standard" Style, by lisp.

.... 


(command "_.style" "STANDARD" "Arial")

(while (> (getvar 'cmdactive) 0) (command ""))

Kent Cooper, AIA
Message 8 of 18

pbejse
Mentor
Mentor

@Kent1Cooper wrote:

@devitg wrote:

Hi Kent. please How could to assign Arial to the "Standard" Style, by lisp.

.... 


(command "_.style" "STANDARD" "Arial")

(while (> (getvar 'cmdactive) 0) (command ""))


I agree, its always good to use command version, Also Mac friendly too.

 

Message 9 of 18

Anonymous
Not applicable

Hallo,

 

There is some difference in width factor. So it is better to keep the styles and change only the font.

If you write accordingly I can use the lisp.

 

Regards

Shameem

 

0 Likes
Message 10 of 18

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

There is some difference in width factor. So it is better to keep the styles and change only the font.

If you write accordingly I can use the lisp.

.... 


Does @Anonymous's suggestion in Post 2 not do that?

Kent Cooper, AIA
0 Likes
Message 11 of 18

Anonymous
Not applicable

Apologies for resurrecting a old thread, but what would I exactly do with the code in Post 2?

It's not a script to be run (I believe it's VBA?) it's also not a Lisp, so what would I do to be able to use that code?

DO I run it in Visual Basic Editor?

0 Likes
Message 12 of 18

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... what would I exactly do with the code in Post 2?  It's ... not a Lisp....


 

Yes, it is  AutoLisp code.  You should be able to just copy and paste it right into the Command: line.  Or you can add more to it to make it into a command definition, and save it to a file, so you can load that and type in the defined command name to use it.  Is that what you're after?

Kent Cooper, AIA
Message 13 of 18

Anonymous
Not applicable

Yes, I think so, thank you.

0 Likes
Message 14 of 18

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:
.... you can add more to it to make it into a command definition, and save it to a file, so you can load that and type in the defined command name to use it.  Is that what you're after?

 

Something like this [untested]:

(defun C:ASAF (/ st); = All Styles Arial Font
  (while (setq st (tblnext "STYLE" (not st)))
    (setq st (entget (tblobjname "STYLE" (cdr (assoc 2 st)))))
    (entmod (subst '(3 . "Arial") (assoc 3 st) st))
  ); while
  (princ)
); defun

Change the ASAF if you want a different command name, and change the blue parts as appropriate if you want a different font applied to all Styles.

 

Save that into a file called something meaningful like AllStylesArialFont.lsp, in some folder location that is listed in the OPTIONS command / Files tab / Support File Search Path list.  Use APPLOAD to load it, and type whatever you end up with as a command name [the part following the C:] to run it.

 

It could also be modified to ask for the font  you want used in all Styles, or to ask but offer a default value.

Kent Cooper, AIA
Message 15 of 18

rkondracki
Community Visitor
Community Visitor

Thanks for the script it seems to be nearly there with what the original poster is asking, but it seems to default to an SHX type font. In my case at least, AutoCAD cannot find this font. Is there something in the code that needs to be changed to point to a TTF file?

0 Likes
Message 16 of 18

Kent1Cooper
Consultant
Consultant

@rkondracki wrote:

... it seems to default to an SHX type font. In my case at least, AutoCAD cannot find this font. Is there something in the code that needs to be changed to point to a TTF file?


Set up a Text Style using the font you want, put this in at the Command line:

  (entget (tblobjname "STYLE" "YourStyleName"))

and look for the entry starting with a 3:

  (3 . "YourFontName")

and use however it has it there in place of Arial in the code.

Kent Cooper, AIA
Message 17 of 18

Anonymous
Not applicable

I have the same issue but I would like to solve it with VBA.

How can I change the Standard Style Font to Arial ?

 

Thank you

0 Likes
Message 18 of 18

Sea-Haven
Mentor
Mentor

 Hmm the answer google "change text style vba autocad"

0 Likes