2 Replies Latest reply on Dec 4, 2011 7:36 PM by steve.westdal

    FindAttribute "DNP" of components DxDesigner Script

    steve.westdal

      Hi

       

      I am developing a script to go through all the parts in a DxDesigner schematic, and gather component attributes.

      This is all working fine, except I also need to extract "DNP" information, which the script can't find, and then explodes violently and ruthlessly.

      As the example code shows below, I extract the "PACKAGE" attribute from the component. In the component properties of the schematic, I can clearly see "PACKAGE". This works fine.

      I can also clearly see the "DNP" property, but for some reason FindAttribute(DBP) returns nothing.

       

      For further background information, I am using dictionaries since they are the only type I am aware of that can expand dynamically. There is one dictionary for each component property attribute. The DEVICE parameter is used as the dictionary key for each.

       

      ----------

       

      Const DEVICE  = "Part Number"

      Const PKG   = "PACKAGE"

      Const DNP   = "DNP"

       

      For Each itr in objDxApp.DesignComponents("", schemName, -1, "STD", TRUE)

          

           'This works fine

           dicKey = itr.FindAttribute(DEVICE).EitherValue

              

           'This works fine

           dicCompPKG.add   dicKey, itr.FindAttribute(PKG).EitherValue

       

           'This blows up

           dicCompDNP.add   dicKey, itr.FindAttribute(DNP).EitherValue

      ----------

       

      Thanks

        • 1. Re: FindAttribute "DNP" of components DxDesigner Script
          john_dube

          Steve,

           

          The DesignComponents method returns a collection of all components in the design (including annotate symbols like borders), it seems likely that not all components have a DNP attribute, so the code should not make that assumption.

           

          You can check whether the attribute exists first, like this:

           

               If Not itr.FindAttribute(DNP) Is Nothing Then

                    dicCompDNP.Add dicKey, itr.FindAttribute(DNP).EitherValue

               End If

           

          Keep in mind that FindAttribute only looks at the attributes on the component instance, not the underlying symbol.  If you need to look at the underlying symbol, get the component's SymbolBlock property and call FindAttribute there.

           

          It could be worth creating a function that looks first at the component instance, then at the symbol block, and cleanly handles the case where the attribute does not exist.  Search the forum here and you can probably find an example.

           

          John

          • 2. Re: FindAttribute "DNP" of components DxDesigner Script
            steve.westdal

            Thanks for the code safety suggestions - I do actually employ them, but didn't include them since it's not what I'm having a problem with.

            For example, I only look at device components, shown below

             

            ----------

             

            For Each itr in objDxApp.DesignComponents("", schemName, -1, "STD", TRUE)

                 If itr.SymbolBlock.SymbolType = VDB_MODULE Then

                      'Grab attributes, do error checking

                 End If   

            Next

            ----------

             

            I have a snapshot shown below of some of the resistor properties. I went ahead and tried itr.SymbolBlock.FindAttribute("DNP").EitherValue, which allows the script to not "blow up", but returns "".  This makes sense, because the Symbol Value is <none>.

            However, what I don't understand is why itr.FindAttribute("DNP").EitherValue *does not* work - why grabbing the Symbol Value is ok but the Block Value is not - because the properties window says the Block Value is "dnp". If I grab the itr.FindAttribute("1ST_MANUFACTURER").EitherValue I will get its Block Value of "Vishay". Strangely, this does not work for DNP.

            This is why I don't understand why the script would blow up on DNP, when it allows 1ST_MANUFACTURER.

             

            properties.JPG

            Thanks Again