Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change All font in Text Style Manager

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
Anonymous
7552 Views, 17 Replies

Change All font in Text Style Manager

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

 

17 REPLIES 17
Message 2 of 18
Anonymous
in reply to: Anonymous

 

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
in reply to: Anonymous


@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
in reply to: Anonymous

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
Message 5 of 18
devitg
in reply to: Kent1Cooper

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

Thanks

 

 

 

Message 6 of 18
pbejse
in reply to: devitg

 

(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
in reply to: devitg


@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
in reply to: Kent1Cooper


@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
in reply to: Kent1Cooper

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

 

Message 10 of 18
Kent1Cooper
in reply to: Anonymous


@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
Message 11 of 18
Anonymous
in reply to: Kent1Cooper

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?

Message 12 of 18
Kent1Cooper
in reply to: Anonymous


@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
in reply to: Kent1Cooper

Yes, I think so, thank you.

Message 14 of 18
Kent1Cooper
in reply to: Kent1Cooper


@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
in reply to: Kent1Cooper

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?

Message 16 of 18
Kent1Cooper
in reply to: rkondracki


@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
in reply to: Kent1Cooper

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

Message 18 of 18
Sea-Haven
in reply to: Anonymous

 Hmm the answer google "change text style vba autocad"

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report