Jump to content
Pat Stanford

Change All Fonts in File

Recommended Posts

The attached script will change the font of all text objects in a drawing, even objects that are part of a group, symbol or viewport annoation. A dialog box allows the user to select the desired font.

Depending on how a PluginObject has been written it might or might not be able to change the font of text that is part of a PIO.

Free for your use.

BACKUP your file before use. No Warranty is Expressed or Implied. Do not operate heavy machinery while using this script. If a rash or sneezing develops for more than 4 hours consult a doctor immediately.

Procedure ChangeAllFonts;

{Changes the font of all text on a drawing to the selected font}
{Traverses into groups, symbols and viewport annotations}

{January 6, 2012}
{? 2012, Coviana, Inc - Pat Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}



var	Hd		:Handle;
Font	:String;
dInt	:Integer;
dReal	:Real;

Procedure ChangeFont(Hd:Handle);

Begin
if GetType(Hd)= 10 then 
begin
	SetTextFont(Hd, 0,len(gettext(Hd)),GetFontID(Font));
end
end;


Begin
Font:='Arial';
FormatTextDialog(Font,dInt,dReal,dInt,dReal,dInt,dInt,62);
ForEachObject(ChangeFont,(INSYMBOL & INOBJECT & INVIEWPORT & (ALL)));
end;

Run(ChangeAllFonts);

Share this post


Link to post

Pat

 

I know this is an old thread but is there any chance this script can  be made to change all the sizes of the font as well?

 

Many thanks

 

Andrew

Share this post


Link to post

Hi Andrew,

   I adapted Pat's script to also set the Point Size of the text. This will set all objects to the same size which could make some documents look weird. You could break the script into two scripts to give you more control. To just set the point size, comment out (or remove) the SetTextFont() command.

 

   You can also make the script work only on SELECTED text objects only by changing the  "& ALL"  to  "& SEL"  in the ForEachObject() command near the bottom.

PROCEDURE ChangeAllFonts;
{ Changes the font of all text on a drawing to the selected font }
{ Traverses into groups, symbols and viewport annotations }

{ January 6, 2012 }
{ © 2012, Coviana, Inc - Pat Stanford pat@coviana.com }
{ Licensed under the GNU Lesser General Public License }

{ 17 February 2020 - R. Mullin }
{ Added ability to set the Point Size of all text objects at the same time. }
{ Same GNU License as above. }

VAR
	Hd :Handle;
	Font :String;
	FontID, dInt :Integer;
	PointSize, dReal	:Real;

	Procedure ChangeFont(Hd:Handle);
	Begin
		if (GetTypeN(Hd) = 10) then begin
			SetTextFont(Hd, 0, len(gettext(Hd)), GetFontID(Font));
			SetTextSize(Hd, 0, len(gettext(Hd)), PointSize);
		end;
	End;

BEGIN
	Font := 'Arial';
	FormatTextDialog(Font, dInt, dReal, dInt, dReal, dInt, dInt, 60);
	ForEachObject(ChangeFont, INSYMBOL & INOBJECT & INVIEWPORT & ALL);
END;
Run(ChangeAllFonts);

 

Raymond

 

  • Like 1

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...