Friday, May 13, 2011

Get pads that make up a component using a group iterator.

Select a PCB component with the GetObject and then using a Group Iterator list all pads and the location of the pads that make up the choosen component.

Sub GetCompPads

Dim Board
Dim Comp
Dim CompGroup
Dim CompPads
Dim x,y
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
While Board.ChooseLocation(x,y, "Choose Pad") = True
      Set Comp = Board.GetObjectAtXYAskUserIfAmbiguous(x,y,MkSet(_
      eComponentObject),AllLayers,eEditAction_Focus)

      If Not(Comp is Nothing)  Then
         Set CompGroup = Comp.GroupIterator_Create
         CompGroup.AddFilter_ObjectSet(MkSet(EpadObject))
         Set CompPad = CompGroup.FirstPCBObject

         While Not(CompPad is Nothing )
           ShowMessage("Pad=" & CompPad.Name & " X=" & CoordToMils(CompPad.X)_
           & " Y=" & CoordToMils(CompPad.Y))
           Set CompPad = CompGroup.NextPCBObject
          Wend

      End If
Wend

End Sub




www.tdpcb.com