1 Reply Latest reply on Aug 23, 2010 11:51 PM by a.sassano

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

    vermaaka

      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

        • 1. Re: Learning to use PADS scripts: how do I display part attributes
          a.sassano

          I don't tested it. Maybe some syntax Problems may exist.

           

          -Original-----------------------------------

          ...

          For Each nextComp In ActiveDocument.Components
            ListComps$(index) = nextComp.Name
            index = index + 1
          Next nextComp

          ...

          -Changed-----------------------------------

          ...

          For Each nextComp In ActiveDocument.Components

            oAttr = nextComp.Attributes("VALUE")

            if oAttr is nothing then     ' Check if Attribute exists
                 ListComps$(index) = "No Value Attribute exists"          ' Or remove line by '

            else

                 ListComps$(index) = oAttr.Value

            end if


            index = index + 1
          Next nextComp

          ...

          ------------------------------------