Altium Scripts
These are some helpful Altium Scripts written in Visual Basic Script
to help you get started with the programming.
This one will replace a portion of a string globally on the layer that
you choose.

'Replace a portion of a string globally
'V0.1 Added Layer ComboBox
Sub Button1Click(Sender)
Dim Board
Dim TextString
Dim TMPString
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
Iterator = Board.BoardIterator_Create
Iterator.AddFilter_ObjectSet(MkSet(eTextObject))
Iterator.AddFilter_LayerSet(MkSet(String2Layer(ComboBox1.Text)))
Iterator.AddFilter_Method(eProcessAll)
Set TextString = Iterator.FirstPCBObject
Call PCBServer.PreProcess
While Not (TextString Is Nothing)
If Instr(TextString.Text, Edit1.Text) Then
TMPString = Replace(TextString.Text, Edit1.Text, Edit2.Text)
TextString.Text = TMPString
End If
Set TextString = Iterator.NextPCBObject
Wend
Board.BoardIterator_Destroy(Iterator)
PCBServer.PostProcess
Call AddStringParameter("Action", "Redraw")
RunProcess("PCB:Zoom")
End Sub
Sub Form1Create(Sender)
Dim Board
Dim Layer
Form1.Caption = Form1.Caption & " V0.1"
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
Iterator = Board.BoardIterator_Create
For Layer = eTopLayer to eMultiLayer
If Board.LayerIsDisplayed(Layer) AND Board.LayerIsUsed(Layer) Then
ComboBox1.Items.Add Layer2string(Layer)
End If
Next
End Sub
Sub ComboBox1Change(Sender)
Dim Board
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
Call PCBServer.PreProcess
SetState_Layer = String2Layer(ComboBox1.Text)
PCBServer.PostProcess
Call AddStringParameter("Action", "Redraw")
RunProcess("PCB:Zoom")
End Sub


Tru Designs is an Altium Service Bureau
|
Tru Designs llc Altium Scripts