0
\$\begingroup\$

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
\$\endgroup\$
2
  • \$\begingroup\$ In the preferences you can set a default size. You don't need script to that. \$\endgroup\$ Jan 17, 2019 at 15:41
  • \$\begingroup\$ 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. \$\endgroup\$
    – schwdk
    Jan 18, 2019 at 8:34

1 Answer 1

1
\$\begingroup\$

See this page for an example: Altium Designer example script

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".

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.