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
Altium Designer Script Information in VB for PCB Layout and Schematic Capture by Bill Smock from Tru Designs, San Diego, CA.
Showing posts with label Iterator. Show all posts
Showing posts with label Iterator. Show all posts
Friday, May 13, 2011
Tuesday, April 19, 2011
Counting Pads
Learn to use an Iterator that creates a set of objects that meet a certain criteria. This will count the number of pads on the board. Use the AddFilter's to include only the objects that you need.
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
http://www.tdpcb.com/
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
http://www.tdpcb.com/
Subscribe to:
Posts (Atom)