Tru Designs llc Altium Scripts
Altium Scripts
These are some helpful Altium Scripts written in Visual Basic Script
to help you get started with the programming.
These are some very basic PCB scripts to show how to count the
number of pads and place a via or a string on the board.

Sub CountPads
Dim Board
Dim Pad
Dim PadNumber
Dim TotalObjects
Padnumber = 0
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
Iterator = Board.BoardIterator_Create
Iterator.AddFilter_ObjectSet(MkSet(ePadObject))
Iterator.AddFilter_LayerSet(AllLayers)
Iterator.AddFilter_Method(eProcessAll)
Set Pad = Iterator.FirstPCBObject
While Not (Pad Is Nothing)
PadNumber = PadNumber + 1
Set Pad = Iterator.NextPCBObject
Wend
Board.BoardIterator_Destroy(Iterator)
ShowMessage(PadNumber & " Were Found")
End Sub
============================================
Sub ViaCreation
Dim Board
Dim Via
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
For I = 1 to 10
' Create a Via object
Via = PCBServer.PCBObjectFactory(eViaObject, eNoDimension,
eCreate_Default)
Via.X = MilsToCoord(500 + (I * 50))
Via.Y = MilsToCoord(5500 +(I * 50))
Via.Size = MilsToCoord(35)
Via.HoleSize = MilsToCoord(15)
Via.LowLayer = eTopLayer
Via.HighLayer = eBottomLayer
' Put this via in the Board object
Board.AddPCBObject(Via)
Next
End Sub
============================================
Sub StringCreation
Dim Board
Dim ASMSting
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
For I = 1 to 10
' Create a String object
ASMString = PCBServer.PCBObjectFactory(eTextObject,
eNoDimension, eCreate_Default)
ASMString.XLocation = Board.XOrigin + I*MilsToCoord(50)
ASMString.YLocation = Board.YOrigin - I*MilsToCoord(100)
ASMString.Layer = eMechanical7
ASMString.Text = "TD" & I
ASMString.Size = MilsToCoord(100)
' Put this string on the Board
Board.AddPCBObject(ASMString)
Next
End Sub


Tru Designs is an Altium Service Bureau
|