1 Reply Latest reply on Jul 29, 2014 9:50 PM by Patrick.Cashman

    Label object doesn't work for component label


      Does someone know why this script doesn´t list the components labels?

      The same script with z=comp.UID works.


      Option Explicit

      Dim DxdApp, Activeboard, stopblock
      Dim Comps, Comp
      Dim Prop 
      Const DEBUG_ENABLE = 1


      Set DxdApp = Application ' Aplicacion Dxdesigner
      Activeboard = DxdApp.GetActiveDesign()

      stopblock = DxdApp.GetProjectData.GetICDBDesignRootBlock(Activeboard)




      Sub main
      dim z

      Set Comps = DxdApp.DesignComponents("", stopblock, "-1", "STD", True)

      For Each Comp in Comps  
              z = Comp.Label.TextString
              MsgOutDB (z)


      Set Comps = Nothing

      End Sub



      Sub MsgOutDB( sMsg )


      If DEBUG_ENABLE = 1 Then
           Call DxdApp.AppendOutput("Debug", sMsg)

      End If

      End Sub





        • 1. Re: Label object doesn't work for component label

          Comp.label.textstring produces the following for every component:




          That is not what you want.


          What you want to do is get the properties (attributes) for the component, then find out which one has the information you need. 


          Here is the basics of what I have successfully used many times to get and set attribute values:


          Dim comps

          Dim comp As ViewDraw.Component

          Dim attr As ViewDraw.Attribute


          'first set comp so that it has a reference to the correct symbol


          comps = view.Query(128, 1)     'gets all selected comps on a sheet




          comps = view.Query(128, 0)     'gets all comps on a sheeet



          for each comp in comps

               attr = comp.FindAttribute("Part Number")

               If Not attr Is Nothing Then

                    pn = attr.Value


                    'you could also do something like:

                    attr.value = "your new value"

               End If




          'another example:




          attr = comp.FindAttribute("Ref Designator")

          If Not attr Is Nothing Then

               refdes_loc = attr.GetLocation

               refdes_size = attr.Size

               refdes_origin = attr.Origin

               refdes_orientation = attr.Orientation


               MsgBox("reference designator not found on subject part")

          End If


          You should also look in the help on the getbatchattributes command.  I will produce a text string that includes all the attributes and their values for a component.


          Hope this helps.