AnsweredAssumed Answered

Learning to use PADS scripts: how do I display part attributes

Question asked by vermaaka on Aug 19, 2010
Latest reply on Aug 23, 2010 by a.sassano

I am starting to learn how to write scripts.  I want to change the script below to list any part attribute, so the line that reads "ListComps$(index) = nextComp.Name"

should fill the list with an attribute I choose instead of reference designators (which is what it currently does).  How do I do that?

 

Then I also want to add this fuctionality to the Tools menu.  Any help would be appreciated.

 

 

Dim ListComps$()

Sub Main
'Allocate arrays component and net names
ReDim ListComps$(ActiveDocument.Components.Count)

index = 0
'Iterate through all components in the database and fill array of names
For Each nextComp In ActiveDocument.Components
  ListComps$(index) = nextComp.Name
  index = index + 1
Next nextComp

Begin Dialog UserDialog 250,336,"Part Hi-Lighter",.CallbackFunc ' %GRID:10,7,1,1
  ListBox 10,21,100,259,ListComps(),.ListBox1
  OKButton 10,308,230,21
  Text 10,7,90,14,"Components",.Text1
  Text 10,287,230,14,"Click on listboxes to select item",.Text3
End Dialog
Dim dlg As UserDialog
Dialog dlg
End Sub

Function CallbackFunc%(DlgItem$, Action%, SuppValue%)
Select Case Action%
  Case 2 ' Value changing or button pressed
   If DlgItem$ = "ListBox1" Then
    'Unselect all objects
    ActiveDocument.SelectObjects(ppcbObjectTypeAll, "", False)
    'Select component by given name
    ActiveDocument.SelectObjects(ppcbObjectTypeComponent, ListComps(SuppValue%), True)
   End If
End Select
End Function

Outcomes