1 2 First Previous 29 Replies Latest reply on Sep 5, 2018 6:36 AM by peter_festesen

    xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation

    fuba

      Hello out there,

       

      is there a way how to readout Attributes which appears multiple

      times on a schematic sheet ? I was trying with this:

       

      Dim attr As ViewDraw.Attribute

          attr = vdApp.ActiveView.Block.FindAttribute("myAttribute")

       

      but it returns only (the first) one attribute. I also tried to query like this

       

       

      Dim objs As ViewDraw.IVdObjs

          objs= vbView.Query(ViewDraw.VdObjectTypeMask.VDM_ATTR, ViewDraw.VdAllOrSelected.VD_ALL)

       

      but also here no success, return count is 0.

       

      Any Idea ?

       

      Thanks

       

       

       

       

       

        • 1. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
          peter_festesen

          Hi - these properties you are looking for - what are they attached to ? The border symbol, or individual symbols .

           

          From what you write, you seem to be looking at Block, with Block being the schematic page ?

           

          Let us know a bit more, and we'll try to help ;-)

          • 2. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
            fuba

            Hello Peter, thanks for this first quick response.

            yes, these Properties are attached to the border.

             

            A colleague of mine is planning several atttributes of

            the same type/name, carrying different values,

            which I should collect for another report.

             

            I am looking here for a way to read them out.

             

            Working with FindAttribute in the past was always ok,

            when having single attributes. But now.

             

            Thanks

             

            Stefan

            • 3. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
              peter_festesen

              I think you need to iterate through all attributes, once you have grabbed the border symbol (=Block)

              #1

              FindAttribute will always just report one property - result is a Attribute Object

              #2

              Your second trial (I haven't ried) looks for properties (attributes) attached to the schematic sheet itself, if I am not misreading the code above)

               

              My suggestion would be :

               

              ColAttr=Block.Attributes 'collection of all attributes on block

              For each oAttr in colAttr

                   <register the properties, probably in an array, dictionary won't work for multiple properties with same name>

              Next 'Atrribute

              1 of 1 people found this helpful
              • 4. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                fuba

                I will check that and will come back on this. Thanks for the suggestions.

                • 6. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                  Patrick.Cashman

                  Peter has the right idea. Get all the attributes and iterate through them.

                  • 7. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                    fuba

                    Hi,

                    I tried like this:

                     

                    Dim Attributes As ViewDraw.IVdObjs
                    Attributes = vdApp.ActiveView.Block.Attributes

                     

                    Dim Attribute As ViewDraw.Attribute

                     

                    Dim sb As StringBuilder
                    sb = New StringBuilder

                     

                    For k As Integer = 1 To Attributes.Count
                        Attribute = Attributes.Item(k)
                        With sb
                            .AppendLine("1-Name:          " & Attribute.Name)
                            .AppendLine("2-Value:          " & Attribute.Value)
                            .AppendLine("3-TextString:    " & Attribute.TextString)
                            '.AppendLine("4-Instance Value: " & Attribute.InstanceValue)
                            .AppendLine("5-Type: " & Attribute.Type)
                            '.AppendLine("5-Instance Type: " & Attribute.InstanceValue)
                            .AppendLine()
                        End With
                    Next

                     

                    xDxAttributes1.png

                     

                    But it doesnt give me a result (count always 0). How to I grab the Border ?

                    I think that might be my problem here ?

                    Thanks for the help

                    • 8. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                      peter_festesen

                      In your example, you use : Attributes = vdApp.ActiveView.Block.Attributes

                      which, If I am not am mistaken, would give you the attributes of the schematic sheet (page if you will) - but thta is not what you want. You need to iterate through all pages in the design, then iterate through all comps (symbols) on each page, then for each comp that is of the correct type (ANNOTATE), list all attributes.

                       

                       

                       

                       

                      I have done it this way

                       

                      1) Walk through the hierarchy of the design (see here: https://communities.mentor.com/docs/DOC-1345#comment-1572

                      I am not sure if you are doing that already. The HierarchyWalker script creates a dictionary of all schematic pages with their full path, then goes though every page.

                      Look at Function WalkDesign in the thread for details.

                       

                      2)  In the listed example in the thread, you have For Each objComp in ActiveView.Query(VDM_COMP, VD_ALL)

                      This is where the fun part starts.

                      We want to find the borders only - they are of type VDB_ANNOTATE, so the code will look like this

                       

                       

                      If objComp.SymbolBlock.SymbolType = VDB_ANNOTATE Then

                           Set colAttr = objComp.SymbolBlock.Attributes

                           For each oAttr in colAttr

                                Listbox1.AddString oAttr.Name &" ; "& oAttr.EitherValue

                           Next 'oAttr

                      End If

                       

                      In my trial here (I am using the efm, not dotNet) I am simply dumping all properties to a listbox, with their name and value.

                       

                      I hope this helps you

                      1 of 1 people found this helpful
                      • 9. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                        fuba

                        Hello Peter,

                        thanks for your good answer. Yes, this helps. I found some of the attributes. But Interesting is, that I still miss a few.

                        I can readout all of the Attributes (see image below) except the ones marked in red.

                        dxd.png

                        Do you have any other ideas, what can be wrong ?

                         

                        Thanks again

                         

                        ...I will go on searching.

                        • 10. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                          peter_festesen

                          That looks a little odd - one thing to check is if the properties that you marked, are defined in the Property Definition Editor in the Library. Easiest way to check tat is to click on the property name and look at the readout at the bottom of the properties window. If it says 'Non-Common property', they are not defined in the Definition File. Other things to look for are space characters before or after the name.

                          What happens if you read out all properties (Listbox in your code or use  AppendOutput to write data to the Output window of DxDesigner, as in

                           

                          If objComp.SymbolBlock.SymbolType = VDB_ANNOTATE Then

                               Set colAttr = objComp.SymbolBlock.Attributes

                               For each oAttr in colAttr

                                    AppendOutput "List Props", "_"&oAttr.Name &"_;"& oAttr.EitherValue

                               Next 'oAttr

                          End If

                           

                          I added a few underscore characters before and after the property name, it helps to identify spaces, you can also use other characters of course ;-)

                          The above will write to a new tab (if it does not already exist)  called 'List Props' in the Output Window in DxD.

                          • 11. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                            fuba

                            Thanks again for the good answers.

                            Regarding your recommendation looking into the Property Definition Editor, I have to wait a little for one of my Libarians.

                             

                            Let me summarise what I have done since yesterday.

                             

                            1. I created a new Design (in VX.2.1) added one single Schematic
                            2. I ran my code/macro and read out successfully all the Attributes which are there.
                            3. I added a Value to one Attribute (in my case: fmt_user = Donald Duck)
                            4. I ran my code/ macro again.
                              1. Obersvation one: I missed one Attribute the 'FORWARD_PCB'
                              2. Obersavation two: I missed the Value of fmt_user = "Donald Duck"
                            5. I let the packager run, - no improvements
                            6. I added an existing Property/Attribute + Value to my Schematic Page (fmt_schem_number=123456789)
                            7. I ran my code/macro again
                              1. the previously added Attribute (fmt_schem_number) and its value is missing.

                             

                            For Reference I add my code here:

                             

                            Private Sub btnScanLegend_Click(sender As System.Object, e As System.EventArgs) Handles btnScanLegend.Click
                             
                                Dim SchematicName As String
                                '# this is the schematic name, not the board
                                SchematicName = vdApp.GetProjectData.GetiCDBDesignRootBlock(vdApp.GetActiveDesign())

                               

                                Dim SchematicSheets As Object
                                SchematicSheets = vdApp.QueryPages(SchematicName)

                               

                                Dim blocks As Object
                                blocks = vdApp.QueryPages(SchematicName)

                               

                                Dim block As ViewDraw.Block

                               

                                Dim cdSchms As ViewDraw.IStringList
                                cdSchms = vdApp.SchematicSheetDocuments.GetAvailableSchematics

                               

                                Dim vdScmSheets As ViewDraw.IStringList
                                vdScmSheets = vdApp.SchematicSheetDocuments.GetAvailableSheets(cdSchms.GetItem(1))

                               

                                Dim msg As String
                                msg = String.Empty

                               

                                '#
                                '# Now we run over all Schematic Sheets
                                '# in the Order like in Dx Navigator (on the left)
                                For theSheetNum As Integer = 1 To blocks.count

                                    block = blocks.item(theSheetNum)


                                    vdDoc = vdApp.SchematicSheetDocuments.Open(SchematicName, (block.SheetNum))

                                    vdDoc.Activate()

                             

                                    Dim doc As ViewDraw.IVdDoc
                                    doc = vdApp.ActiveDocument

                             

                                    Dim docName As String = doc.Name
                                    Dim vdShName As String = docName.Substring(InStr(docName, "."))

                             

                                    msg = "Working on Sheet: " & theSheetNum & " / " & blocks.count & " --> " & vdShName
                                    Debug.Print(msg)
                                    Me.UpdateRtb(msg, Color.Blue)

                             

                                    If 1 Then

                                        '#
                                        '# Queries ONLY the current active schematic/symbol
                                        '# file in DxDesigner (e.g. queries only the current "view")

                                        Dim Components As ViewDraw.IVdObjs
                                        Components = vdApp.ActiveView.Query(ViewDraw.VdObjectTypeMask.VDM_COMP, ViewDraw.VdAllOrSelected.VD_ALL)

                             

                                        For j As Integer = 1 To Components.Count

                             

                                            Dim Component As ViewDraw.Component = Components.Item(j)

                             

                                            msg = "Working on Obj: " & j & " / " & Components.Count
                                            Debug.Print(msg)
                                            Me.UpdateRtb(msg, Color.BlueViolet)

                             

                                            If Component.SymbolBlock.SymbolType = ViewDraw.VdSymbolType.VDB_ANNOTATE Then

                             

                                                Dim colAttr As ViewDraw.IVdObjs
                                                colAttr = Component.SymbolBlock.Attributes

                             

                                                For k As Integer = 1 To colAttr.Count

                                                    Dim oAttr As ViewDraw.Attribute
                                                    oAttr = colAttr.Item(k)

                             

                                                    Dim sb As StringBuilder
                                                    sb = New StringBuilder


                                                    With sb
                                                        .AppendLine("Attrib            : *" & k & " / " & colAttr.Count)
                                                        .AppendLine("  1-Name          : *" & oAttr.Name & "*")
                                                        .AppendLine("  2-Type          : *" & oAttr.Type & "*")
                                                        .AppendLine("  3-Value         : *" & oAttr.Value & "*")
                                                        .AppendLine("  4-TextString    : *" & oAttr.TextString & "*")
                                                        .AppendLine("  5-Instance Type : *" & oAttr.InstanceValue & "*")
                                                        .AppendLine("  6-Instance Value: *" & oAttr.InstanceValue & "*")
                                                        .AppendLine()
                                                    End With

                             

                                                    Debug.Print(sb.ToString)
                                                    Me.UpdateRtb(sb.ToString, Color.Black)

                             

                                                    If oAttr.Name = "fmt_sheet_backup" Then
                                                        Debug.Print("DebugStop")
                                                    End If

                                                Next k

                                            End If

                             

                                            If Component.SymbolBlock.SymbolType = ViewDraw.VdSymbolType.VDB_COMPOSITE Then
                                                Debug.Print("DebugStop")
                                            End If

                             

                                            If Component.SymbolBlock.SymbolType = ViewDraw.VdSymbolType.VDB_MODULE Then
                                                Debug.Print("RefDes : " & Component.Refdes)
                                            End If

                             

                                            If Component.SymbolBlock.SymbolType = ViewDraw.VdSymbolType.VDB_PIN Then
                                                Debug.Print("DebugStop")
                                            End If

                             

                                        Next j

                                    End If

                             

                                    '# Close the Doc to save RAM
                                    doc.Close(False, vdScmSheets.GetItem(theSheetNum))

                                Next

                             

                            End Sub

                             

                            I also checked in the Library "CentLib.prp" which keeps Property Definitions for our Company Setup.

                            I think if a Attribute/Property is not listed in here it is marked as "Non Common Property".

                             

                            But now another question for clarification, Where is the difference between an

                            "Annotation" (SymbolType=VDB_ANNOTATE) and a Property on a Component where SymbolType=VDB_MODULE ?

                             

                            Just for completeness, thats the way i add my attributes:

                            propAdd-1.pngpropAdd-2.png

                             

                             

                             

                            Thanks again

                            • 12. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                              fuba

                              Ok, I found it.

                               

                              Peter, you recommended, which was quite good, but gining not all of the Attributes and not all Values (pls see my post from above):

                                 Set colAttr = objComp.SymbolBlock.Attributes

                                  For each oAttr in colAttr

                                        AppendOutput "List Props", "_"&oAttr.Name &"_;"& oAttr.EitherValue

                                  Next 'oAttr

                               

                              After some deep dive I changed to:

                                 Set colAttr = objComp.Attributes

                                  For each oAttr in colAttr

                                        AppendOutput "List Props", "_"&oAttr.Name &"_;"& oAttr.EitherValue

                                  Next 'oAttr

                               

                              This is giving me now all Attributes and Values.

                              If you change/add that line in my code example, you will get different results.

                              Can someone explain why ? Where is the diff between the lists ?

                               

                              Hope this Thread here is helpful for others.

                               

                               

                               

                               

                              • 13. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                                Patrick.Cashman

                                There is a difference between component attributes and component symbol attributes.

                                 

                                The view has a block.  This block has no attributes.

                                The view has components.  One of them is a border.  The border component has attributes, that typically fill the title block and so on. Each of the component attributes has a value (probably, but it could be blank).  The border component has a symbol block.  The symbol block has attributes, and they are all blank.

                                 

                                This code demonstrates the differences:

                                 

                                 

                                Sub list_sheet_attributes()

                                         Dim n, i, j As Integer

                                         Dim attr As ViewDraw.Attribute

                                         Dim view As ViewDraw.View

                                         Dim blok As ViewDraw.Block

                                         Dim attrs As ViewDraw.Objects

                                         Dim comps As ViewDraw.IVdObjs

                                         Dim comp As ViewDraw.Component

                                 

                                         For n = 1 To sheet_names.Count

                                             app.SchematicSheetDocuments.Open(design_name, n)

                                             view = app.ActiveView

                                 

                                             Debug.Print(vbCrLf & vbCrLf & "Sheet " & n)

                                 

                                             blok = view.Block

                                 

                                             Debug.Print(vbCrLf & "view block attributes:")

                                             attrs = blok.Attributes

                                             Debug.Print("there are " & attrs.Count & " attributes on the view block")

                                             For j = 1 To attrs.Count

                                                 attr = attrs.Item(j)

                                                 Debug.Print(attr.Name & vbTab & attr.Value)

                                             Next

                                 

                                             Debug.Print(vbCrLf & "view.blok.getbatchattributes: ")

                                             Debug.Print(blok.GetBatchAttributes)

                                 

                                             Debug.Print(vbCrLf & "Border component attributes:")

                                             comps = view.Query(128, 0)

                                 

                                             For i = 1 To comps.Count

                                                 comp = comps.Item(i)

                                 

                                                 blok = comp.SymbolBlock

                                                 If blok.SymbolType = 3 And blok.LibraryName = "Border" Then

                                                     Debug.Print(vbCrLf & comp.SymbolBlock.GetName(2) & ":")

                                 

                                                     Debug.Print(vbCrLf & "component attributes:")

                                                     attrs = comp.Attributes

                                                     For j = 1 To attrs.Count

                                                         attr = attrs.Item(j)

                                                         Debug.Print(attr.Name & vbTab & attr.Value)

                                                     Next

                                 

                                                     Debug.Print(vbCrLf & "symbol block attributes:")

                                                     attrs = blok.Attributes

                                                     For j = 1 To attrs.Count

                                                         attr = attrs.Item(j)

                                                         Debug.Print(attr.Name & vbTab & attr.Value)

                                                     Next

                                 

                                                     Debug.Print(vbCrLf & "symbol block getbatchattributes:")

                                                     Debug.Print(blok.GetBatchAttributes)

                                 

                                 

                                                 End If

                                             Next

                                         Next

                                End Sub

                                 

                                My output from this is:

                                 

                                Sheet 1

                                 

                                view block attributes:

                                there are 0 attributes on the view block

                                 

                                view.blok.getbatchattributes:

                                 

                                 

                                Border component attributes:

                                 

                                BORDER_B_SIZE_1:

                                 

                                component attributes:

                                @PRINTORDER   

                                @SHEETTOTAL    21

                                ApprovedBy    John Smith

                                ApprovedDate    01AUG17

                                CheckedBy    Davey Jones

                                CheckedDate    01AUG17

                                DrawnBy    Rene Descartes

                                DrawnDate    01AUG17

                                MATNO    141191

                                SMTNO    141192

                                Title    RECEIVE IF

                                DrawingNumber    10000044683

                                Revision    AA

                                Revision-2    AA

                                @SHEET    5

                                 

                                symbol block attributes:

                                Title   

                                SMTNO   

                                MATNO   

                                DrawnDate   

                                DrawnBy   

                                CheckedDate   

                                CheckedBy   

                                ApprovedDate   

                                ApprovedBy   

                                @SHEETTOTAL   

                                @SHEET   

                                Revision-2   

                                Revision   

                                DrawingNumber   

                                 

                                symbol block getbatchattributes:

                                0 Title=

                                0 SMTNO=

                                0 MATNO=

                                0 DrawnDate=

                                0 DrawnBy=

                                0 CheckedDate=

                                0 CheckedBy=

                                0 ApprovedDate=

                                0 ApprovedBy=

                                3 @SHEETTOTAL=

                                3 @SHEET=

                                0 Revision-2=

                                3 Revision=

                                3 DrawingNumber=

                                • 14. Re: xDxDesigner - readout Attribute which is multiple times on the same Sheet via Automation
                                  peter_festesen

                                  Hi - are you saying that objComp.SymbolBlock.Attributes gives you a different collection than objComp.Attributes ?

                                   

                                  BTW thanks for replying with the whole story also on NonCommon properties. That was a useful detail.

                                   

                                  Please confirm, and I'll do some digging.

                                  /Peter

                                  1 2 First Previous