1 Reply Latest reply on Nov 17, 2016 12:18 PM by Kenji Hashimoto

    Regroup and Ungroup in Process Book Display in VBA

    RonaldMain

      Hi I've been working on process Book Display to do the following

      The Display contains some symbols previously defined

      for example : pbSymbolText(Tag Value, Tag Name)

      They are grouped (symbol type = 0)

      Like this there are 10 groups

       

       

      I want to take each group and extract the tag name in a string array.

      Then I will do my stuff ...

       

      My issue is that I am unable to get the Contents(Text) when the symbols are grouped.

      However, when I ungroup, I am able to get the content(Tag Name).

      But when I iterate to next group it gives an error at

      ThisDisplay.SelectedSymbols.Ungroup             - The property or method is unsupported.

       

      In the end I want the tags Name and Tag value to be grouped as before.

      Also, can you give links of how to dynamically set size of string array, is there a way to use List/Vectors in VBA?

      and optimised code for  If Not() statement I've used---- > I feel this is bit unreadable

       

       

       

      Dim ExistObjects(100) As String
      Dim i As Integer
      i = 1
      Dim t As Text
      Dim s As Symbol
      
      
      For Each r In ThisDisplay.Symbols
      r.Selected = False
      Next r
      
      
      For Each s In ThisDisplay.Symbols
         
          If s.Type = 0 Then
            s.Selected = True
            ThisDisplay.SelectedSymbols.Ungroup
          
               For Each Sym In ThisDisplay.Symbols
                       If Sym.Type = pbSymbolText Then
                           Set t = Sym
                           If Not ((t.Contents = "Device Alert") Or (t.Contents = "In Service") Or (t.Contents = "Not In Service") Or (t.Contents = "Malfunction")) Then
                           ExistObjects(i) = t.Contents
                           i = i + 1
                           End If
                       End If
               Next Sym
                 End If
      Next s
      
        • Re: Regroup and Ungroup in Process Book Display in VBA
          Kenji Hashimoto

          I think you can retrieve symbols without ungroup.

          For example

              For Each Sym In ThisDisplay.Symbols
                  If TypeOf Sym Is Composite Then
                      Set comp = Sym
            
                      For Each compsym In comp.GroupedSymbols
                         If compsym.Type = pbSymbolValue Then
                             MsgBox (compsym.GetTagName(1))
                         End If
                      Next compsym
                  End If
               Next Sym
          

           

          This code runs correctly if the display contains grouped object and pbSymbolValue objects. It shows tag name...

          You said that you are using pbSymbolText(Tag Value, Tag Name). I don't understand well about it. If you can explain it more, we can support you for more details.

          1 of 1 people found this helpful