4 Replies Latest reply on Jul 29, 2016 7:05 PM by jmitchell@triencon

    Assign Processbook Button to AF Template

    jmitchell@triencon

      I need to assign a PB button to an AF template. The idea being that, there would be attributes in the element template that would store the button's configuration details, so that when the symbol (in this case, the button) is dragged to the display, those AF elements automatically populate the button configuration details. Anyone done this? I've successfully used values, text, and multi-states, but this usage escapes me.

        • Re: Assign Processbook Button to AF Template
          pmartin

          Hi James,

           

          I think the best way to tackle this is to use VBA in ProcessBook.  Since our solution is going to involve code, I've moved this topic to the PI Developers Club.

           

          I've written a quick example project using VBA to highlight how you could change the properties of an object based on Element-Relative inputs.  The attribute I chose to modify was the FillColor.  Unfortunately, button FillColor can't be changed as is discussed in PI Processbook button color.  As such, I used the workaround proposed by Karl.

           

          First, I created a simple AF hierarchy.  Each element in the hierarchy has one attribute, FillColor, that is just a string that contains the RGB values.

          Next, I added a value object in ProcessBook.  I enabled scripting for this object and set its visibility to false.  This value object is configured to read the Element Relative property FillColor.

          Finally, in the VBA editor, I use the DataUpdate function for Value1 to split the FillColor string in to Red, Green, and Blue values.  These values are sent in to the FillColor property of my rectangle.

          Private Sub Value1_DataUpdate()
              Dim Colors() As String
              Dim vrDate As Variant
              Dim vrStatus As Variant
              
              Colors() = Split(Value1.GetValue(vrDate, vrStatus), ",")
              Rectangle1.FillColor = RGB(Colors(0), Colors(1), Colors(2))
          End Sub
          

           

          Hopefully this helps!  I wasn't 100% sure what you were asking so let me know if I missed the mark.

            • Re: Assign Processbook Button to AF Template
              jmitchell@triencon

              Thanks for the information and taking the time to do this.

               

              However, I intentionally left out a critical piece of information when I posted this on PI Square. The reason I left it out was to prevent folks from reading the posting and automatically using the default “Oh, that just can’t be done.”

               

              The part I left out is this: 99% of our user audience will view these displays in Coresight. We edit the displays in Processbook because display creation / building just isn’t ‘there’ yet in Coresight. Now it is my understanding that Coresight currently doesn’t support VB, hence my leaving this info out in my original post. Unless you know otherwise.

               

              It was my hope that there would be a solution that didn’t involve VB code for this reason. But I see that full symbol association with an AF template either wasn’t fully thought out or what I’m wanting to do just isn’t possible at this time (yep, rhetorical wording).

               

              At any rate, thanks again for the response, and I will ferret this little bit of info away in my PB library that I keep for myself.

               

              James Mitchell