2 Replies Latest reply on Dec 20, 2017 8:20 AM by Patrick.Cashman

    How to detect a Missing Instance Level Property in DxDesigner

    peter_festesen

      Hi - this time I am the one who needs help ;-)

       

      I have a situation where I need to detect whether a symbol has a property or not. The problem is that

      objAttr.InstanceValue, objAttr.EitherValue both give me '' in the case where

      Instance Value is <none> or Instance Value is undefined.

       

      Here, Instance Level property value is undefined

       

      Here, Instance Level property value is defined, but empty

       

      Things tried :

      #1

      Hoping for an error that I then could address by using "Error Resume Next / On Error Goto 0", I tried Attribute.DeleteInstanceValue()

      My hope was that the method would give an error if InstanceValue was missing - it doesn't.

       

      #2

      Also looked at the hidden methods/properties of the 'Attribute' object (via Excels Object Browser)  - no such luck.

       

      #3

      Tried to use On Error Resume Next with objAttr.DeleteInstanceValue. I thought it worked until I found that also the second case, where Instance VAlue is defined, but blan, it also Errrors out.

       

      So this is my last resort, hoping that someone has encountered this problem before....

        • 1. Re: How to detect a Missing Instance Level Property in DxDesigner
          fuba

          Hello Peter,

          maybe your situation is similar to mine here:

          https://communities.mentor.com/message/71266#comment-71266

          And if you take an other attribute collection, (pls see my post #12) than you find your solution.

          • 2. Re: How to detect a Missing Instance Level Property in DxDesigner
            Patrick.Cashman

            With this code, modified slightly from the other thread:

                 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 1

                         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 & vbTab & "Instance Value: " & attr.InstanceValue)

                                 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 & vbTab & "Instance Value: " & attr.InstanceValue)

                                 Next

             

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

                                 Debug.Print(blok.GetBatchAttributes)

             

             

                             End If

                         Next

                     Next

            End Sub

             

            I get the following output:

             

            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        Instance Value: 6

            @SHEETTOTAL    21    Instance Value: 21

            ApprovedBy    John Smith    Instance Value:

            ApprovedDate    01AUG17    Instance Value:

            CheckedBy    Davey Jones    Instance Value:

            CheckedDate    01AUG17    Instance Value:

            DrawnBy    Rene Descartes    Instance Value:

            DrawnDate    01AUG17    Instance Value:

            MATNO    141191    Instance Value:

            SMTNO    141192    Instance Value:

            Title    RECEIVE IF    Instance Value:

            DrawingNumber    10000044683    Instance Value:

            Revision    AA    Instance Value:

            Revision-2    AA    Instance Value:

            @SHEET    6    Instance Value:

             

            symbol block attributes:

            Title        Instance Value:

            SMTNO        Instance Value:

            MATNO        Instance Value:

            DrawnDate        Instance Value:

            DrawnBy        Instance Value:

            CheckedDate        Instance Value:

            CheckedBy        Instance Value:

            ApprovedDate        Instance Value:

            ApprovedBy        Instance Value:

            @SHEETTOTAL        Instance Value:

            @SHEET        Instance Value:

            Revision-2        Instance Value:

            Revision        Instance Value:

            DrawingNumber        Instance Value:

             

            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=