Altium Scripts

These are some helpful Altium Scripts written in Visual Basic Script
to help you get started with the programming.
This will list the net classes and allow you to show or hide the net
connections in that net class. It's a little slow with large net list but
it's still pretty handy.
'www.tdpcb.com
'This will list the Net Classes and allow to you just show or hide the
'connections for the nets in that class.
Sub Form1Create(Sender)
Dim Iterator
Dim Board
Dim NetClass

Form1.Caption = Form1.Caption & " V0.1"

' Checks if the current document is a PCB document
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub

Iterator = Board.BoardIterator_Create
Iterator.AddFilter_ObjectSet(MkSet(eClassObject))
Iterator.AddFilter_LayerSet(AllLayers)
Set NetClass = Iterator.FirstPCBObject

While Not (NetClass Is Nothing) 'Get Net Classes
 If NetClass.MemberKind = eClassMemberKind_Net Then
    If NetClass.Name <> "All Nets" Then  'Ignore the All Nets class
       ComboBox1.Items.Add NetClass.Name
    End If
 End if
 Set NetClass = Iterator.NextPcbObject
Wend
ComboBox1.Text = ComboBox1.Items(0)
Board.BoardIterator_Destroy(Iterator)
End Sub

Sub Button1Click(Sender) 'Show Connections
 GetClassNets (1)
End Sub

Sub Button2Click(Sender) 'Hide Connections
 GetClassNets (0)
End Sub

Sub GetClassNets( State )
Dim Iterator
Dim Board
Dim NetClass
Dim I
I = 0
' Checks if the current document is a PCB document
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub

Iterator = Board.BoardIterator_Create
Iterator.AddFilter_ObjectSet(MkSet(eClassObject))
Iterator.AddFilter_LayerSet(AllLayers)
Set NetClass = Iterator.FirstPCBObject

While Not (NetClass Is Nothing)
 If NetClass.MemberKind = eClassMemberKind_Net Then
    If NetClass.Name = ComboBox1.text Then
       While  (NetClass.MemberName(I) <> "") 'Get Memebers of Net Class
         If State = 1 Then 'Turn Connections ON
            RetVal = RatsNest (NetClass.MemberName(I),1)
         Else              'Turn Connections OFF
            RetVal = RatsNest (NetClass.MemberName(I),0)
         End If
         I = I + 1
       Wend
    End If
    I = 0
 End if
 Set NetClass = Iterator.NextPcbObject
Wend

Board.BoardIterator_Destroy(Iterator)
End Sub


Function RatsNest( NetName, State ) 'Turn Net Connection ON or OFF
Dim Board
Dim Net
Dim Iterator
Dim I
I = 0
Call PCBServer.PreProcess
Set Board = PCBServer.GetCurrentPCBBoard
Iterator = Board.BoardIterator_Create
Iterator.AddFilter_ObjectSet(MkSet(eNetObject))
Iterator.AddFilter_LayerSet(AllLayers)
Iterator.AddFilter_Method(eProcessAll)
Set Net = Iterator.FirstPCBObject

While (Not (Net Is Nothing)) AND I = 0 'Look for net name
 If Net.Name = NetName Then
    If State = 1 then
      Net.ConnectsVisible = True
      I = 1 'Set to leave loop, no need to keep looking
    Else
      Net.ConnectsVisible = False
      I = 1 'Set to leave loop, no need to keep looking
    End If
 End If
 Set Net = Iterator.NextPcbObject
Wend

Board.BoardIterator_Destroy(Iterator)
PCBServer.PostProcess
Call AddStringParameter("Action", "Redraw")
RunProcess("PCB:Zoom")

End Function
Tru Designs is an
Altium Service Bureau
Tru Designs llc   Altium Scripts