5 Replies Latest reply on Apr 13, 2015 6:48 PM by fdesu

    como puedo hacer visible o no una layer de PB con VBA in button?

    ArielPereira

      como puedo hacer visible o no una layer de PB con VBA in button?

       

      [English translation: How can I make a layer in PB visible or invisible with VBA in a button?]

      [Moving the thread to PI Visualization space because it is related to the topic.]

        • Re: como puedo hacer visible o no una layer de PB con VBA in button?
          dng

          Hi Ariel,

           

          I hope I understood your question correctly, are you asking if we can show or hide a Processbook layer with a button using VBA?


          If so, here is a code snippet that toggles the visibility of "Layer1" in a ProcessBook display using a button:

           

          Private Sub CommandButton1_Click()
              Dim status As Boolean
              status = ThisDisplay.Layers("Layer1").Visible
              If (status = True) Then
                  ThisDisplay.Layers("Layer1").Visible = False
              Else
                  ThisDisplay.Layers("Layer1").Visible = True
              End If
          End Sub
          

           

          Hope it helps! Let me know if you have any questions.

            • Re: como puedo hacer visible o no una layer de PB con VBA in button?
              fdesu

              Im looking something like this, but for all texts!! do you know how can do that ?

                • Re: como puedo hacer visible o no una layer de PB con VBA in button?
                  dng

                  Hi Francisco,

                   

                  Are you using layers? If not, what kind of symbols would you like to hide? On each ProcessBook displays, there are usually different types of "symbols". E.g.

                  • Text: similar to textbox where you can type in text
                  • Value: display the value of a PI tag, AF attribute, etc.
                  • Trend: time-series plot
                  • Bar: bar graph
                  • etc.

                   

                  The different types of symbols are stored in the pbSYMBOLTYPE enumeration. I am going to give you an example that hides all the Text symbols on the processbook display. Feel free to modify the example to hide all the symbols you consider as "texts".

                   

                  ' Note: CommandButton1 by default has the caption "Hide Text"
                  Private Sub CommandButton1_Click()
                     
                      ' store all symbols in the processbookd display
                      Dim syms As Symbols
                     
                      ' isHide is true if we want to hide the symbols, else false
                      Dim isHide As Boolean
                     
                      ' Toggle dislay caption of the button
                      If CommandButton1.Caption = "Hide Text" Then
                          isHide = True
                          CommandButton1.Caption = "Show Text"
                      Else
                          isHide = False
                          CommandButton1.Caption = "Hide Text"
                      End If
                     
                      Set syms = ThisDisplay.Symbols
                      ' loop through all symbols to hide (or show) the text symbols
                      For i = 1 To syms.Count
                          If (syms(i).Type = pbSYMBOLTYPE.pbSymbolText) Then
                              If (isHide) Then
                                  syms(i).Visible = False
                              Else
                                  syms(i).Visible = True
                              End If
                          End If
                      Next i
                         
                  End Sub
                  
                  1 of 1 people found this helpful
              • Re: como puedo hacer visible o no una layer de PB con VBA in button?
                aseck

                Hello Ariel,

                Did Daphne's suggestion help you realize what you wanted? If so, it would help others if you mark the answer that helped you as correct, otherwise you can give us more details so we can further assist you.

                Thanks,

                Alasssane