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
Iterator.AddFilter_ObjectSet(MkSet(eComponentObject))
Iterator.AddFilter_LayerSet(AllLayers)
Iterator.AddFilter_Method(eProcessAll)
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)
Call PCBServer.SendMessageToRobots(CompDes.Name.I_ObjectAddress, c_Broadcast, PCBM_BeginModify, c_NoEventData)
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
Call PCBServer.SendMessageToRobots(CompDes.Name.I_ObjectAddress, c_Broadcast, PCBM_EndModify , c_NoEventData)
Call PCBServer.SendMessageToRobots(CompDes.Name.I_ObjectAddress, c_Broadcast, PCBM_BeginModify, c_NoEventData)
CompDes.ChangeNameAutoposition = eAutoPos_CenterCenter
Call PCBServer.SendMessageToRobots(CompDes.Name.I_ObjectAddress, c_Broadcast, PCBM_EndModify , c_NoEventData)
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
Call AddStringParameter("Action", "Redraw")
RunProcess("PCB:Zoom")
End Sub