# How to change Designator text size by script in Altium 17 or newer

For the assembly drawing I have to move all the designators to a prefefined layer, rotate them as needed and set the text size. I know this is possible via "find similar objects" but I would like to do it via a script. I found a Vb script which is able to set the layer and rotation but the VB API does seems to not supporting a change of the text size. CompDes.Name.Height=0.5 does not work. Our default text font is "TrueType".

This VB script will rotate the designators in one of two ways, center them on the component and move it to the desired layer.

Please help me to set the Text size via script. (Conversion of the script to Delphi is also an option)

Sub RotateDesignators
Dim Board
Dim Component
Dim CompDes
Dim I

Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub

Iterator = Board.BoardIterator_Create

Set CompDes = Iterator.FirstPCBObject
PCBServer.PreProcess
I = 0

'Mech Layer 1 Layer Idx = 57
MechL1 = 57
TopDesignator = MechL1 + 12
BotDesignator = MechL1 + 13

While Not (CompDes Is Nothing)

I = I + 1

If CompDes.Layer = eTopLayer then           'Component is on the top

Select Case CompDes.Rotation
Case 0, 180, 360
CompDes.Name.Rotation  = 0
Case 90, 270
CompDes.Name.Rotation  = 90
End Select
CompDes.Name.Layer = TopDesignator

else                                     'Component is on the bottom

Select Case CompDes.Rotation
Case 0, 180, 360
CompDes.Name.Rotation  = 0
Case 90, 270
CompDes.Name.Rotation  = 270
End Select
CompDes.Name.Layer = BotDesignator
End If

CompDes.ChangeNameAutoposition = eAutoPos_CenterCenter

Set CompDes = Iterator.NextPCBObject
Wend

'ShowMessage(I & " were found") 'Uncomment this line if you want a message after it has finished.
Board.BoardIterator_Destroy(Iterator)

Pcbserver.PostProcess
RunProcess("PCB:Zoom")
End Sub

• In the preferences you can set a default size. You don't need script to that. – Drew Fowler Jan 17 '19 at 15:41
• We would like to have the assembly output print defined completely in the outjob and independent on the used PC and its default Text size from the preferences. – schwdk Jan 18 '19 at 8:34

The relevant part is:

OldUseTTFonts := Designator.UseTTFonts;
OldItalic     := Designator.Italic;
OldBold       := Designator.Bold;
OldInverted   := Designator.Inverted;
OldFontName   := Designator.FontName;
OldFontID     := Designator.FontID;
OldRotation   := Designator.Rotation;


to save the current status, the other way round to assign some new settings. You'll neeed to find out if FontId is still relevant (trial and error)

Here is a reference to ADs IPCB_Text object with the associated methods/properties. You'll need to scroll down pretty far or do a search for "IPCB_Text interface".