7 Replies Latest reply on Apr 16, 2015 2:05 PM by dng

    PROGRAMMATICALLY create AF Elements in a ProcessBook display using VBA.

    RobFerguson1

      I am attempting to PROGRAMMATICALLY create AF Elements in a ProcessBook display using VBA.

       

      Does anyone have an example?

       

      I can do it with drag and drop but we need to drive the action from a VBA macro to draw out several hundred elements and show our model.

        • Re: PROGRAMMATICALLY create AF Elements in a ProcessBook display using VBA.
          dng

          Hi Nigel,


          You will need to use the PI AF SDK to access the AF structure. However, VBA is COM-based while AF SDK is a .NET library; therefore, you will need build a wrapper to use AF SDK in VBA. As an example, check out the AFSDK wrapper for PI Processbook in the Tech Support Download Center.

           

          Before we go that route, is there a reason you would like to build your AF structure in VBA? If you are writing in .NET (e.g. VB.NET or C#), you will not need a wrapper to use the PI AF SDK.

           

           

          Regarding your request on specific code to create AF Elements, please check out the examples in the AF SDK user guide (located in %pihome%\help\afsdk.chm after installing the AF Developers Tools). Specifically, there are example on how to create AF elements if you search or navigate to the AFElement Class.

            • Re: PROGRAMMATICALLY create AF Elements in a ProcessBook display using VBA.
              RobFerguson1

              Hello - Thanks for your suggestions.  The AFSDK/PPI PB Wrapper examples are not quite what I want to do but useful all the same in another context.

              We are trying to build a tool that draws the model objects on to the display at the locations we have already mapped out using Visio.   Once we have done this the displays then need to work with the Modeller AddIn.

              What I have done now is to associate the PB Objects we have with the templates in AF, use the Import Display function provided by Modeller AddIn and then programmatically relocate each symbol to the correct place.   There is a problem with Flows using this method because of the way Modeller Addin implements them but this is more efficient than trying to do it all manually.

              Regards

              Nigel Ferguson

                • Re: PROGRAMMATICALLY create AF Elements in a ProcessBook display using VBA.
                  dng

                  Hi Nigel,

                   

                  Are you referring to the AF Modeler add-in for PI ProcessBook? The AF Modeler add-in is no longer an OSIsoft product, it's owned and supported by the Sigmafine group at Pimsoft now.

                   

                  To give you more information, we do have a new AF Display Builder add-in that was introduced in PI ProcessBook 2014. The AF Display Builder allows users to visualize AF Element hierarchies and Element Attributes as well as build symbols relating to AF data and then assign those symbols to Elements or Element Templates. This promotes easy display building and reusable symbols that are already configured with data from Element Attributes. Furthermore, the AF Display Builder leverages the AF2 DataSet for better data access performance than its predecessor, the PI AF Modeler add-in. Note that you can only view or change the AF attribute values, but you will not be able to rename or change any configurations. PI System Explorer is the preferred client tool to edit the AF database.

                    • Re: PROGRAMMATICALLY create AF Elements in a ProcessBook display using VBA.
                      RobFerguson1

                      Hello Daphne

                       

                       

                       

                      It is the Pimsoft AddIn to which I refer, it may now be owned by Pimsoft but active support is not something they practice as a company despite being paid heavy annual fees for this service.   Nor do we see much useful development of the Sigmafine product suite happening since 2009/2010, it is a great shame.

                       

                       

                       

                      So yes I think I saw another thread on a PI Square forum by some others, (maybe someone in Russia?), who was developing a new AF Display Builder.   saw some visual examples but could not find the binaries to make use of.  So yes if you have more information about OSIsoft own AF Display Builder that would be of great interest.   

                       

                       

                       

                      It would be of even more interest if it is generic and not intimately tied to Process Book because we may then be able to integrate it directly from VISO !

                       

                       

                       

                       

                       

                      Best Regards

                       

                      Rob Ferguson

                       

                      UKM : +44 (0)7767 317486

                       

                      UK : +44 (0)1330 830038

                       

                       

                        • Re: PROGRAMMATICALLY create AF Elements in a ProcessBook display using VBA.
                          dng

                          Hi Nigel,

                           

                          As a disclaimer, our AF Browser only allows visualization of the AF structure within PI ProcessBook, you cannot change the AF structure. Nonetheless, if you are interested, it is built as a docking window in PI ProcessBook, and then the AF UI library was used to add the element hierarchy. There is a ProcessBook add-in project for download in the Tech Support Download Center here. In addition, there is an example on how to add WPF items into the docking window at this thread.

                           

                          If your ultimate goal is to integrate with Visio, it might be easiest to not go through PI ProcessBook since any programmatic access to AF from PI ProcessBook requires VBA, and you can program in VBA directly from Visio. Perhaps we can revisit the idea of wrapping the PI AF SDK to be directly used in Visio VBA code? You will only need to wrap specific methods related to AF Element creation.


                          If you have an example of your Visio diagram and the intended resulting AF structure, we can further take a look and see if this is feasible.

                            • Re: PROGRAMMATICALLY create AF Elements in a ProcessBook display using VBA.
                              RobFerguson1

                              Daphne

                               

                               

                               

                              Thanks for your hints again.   At the moment we are tied in to getting something displayed on Process Book because that is what the final client on this job wants.  This is Takreer Ruwais Refinery in Abu Dhabi, the control system vendor is Yokogawa and the company I am working for is Definit Consulting.

                               

                               

                               

                              For now I will stick with what I have achieved so far, I now have a VB routine that is moving the display objects around according to the display layout dictated by VISO and to this we add some AF data to show results from cases.

                               

                               

                               

                              You are however correct that our ultimate aim is two things:-

                               

                              1)         to take our Model Builder tool (VISO Based) and offer clients this as the normal user interface for Balance Models

                               

                              2)         for clients that want to stick with ProcessBook then provide an AddIn similar to Pimsoft Modeler but with substantially better functionality, primarily allowing paged displays, placing AF data automatically adjacent meter, tank and flow symbols on the display, auto creating diagnostic multi-states depending on statistic tests for each meter and connector layouts that are not tangled!  (a short list!)

                               

                               

                               

                              We plan to progress both of the above over the summer, but for now I have a month in the desert commissioning what we have prepared for the customer on their site and doing some user training.

                               

                              This comprises 8 models of various parts of the plant, the overall model is about 30 A3 Visio Pages making it actually unworkable in PB using the Pimsoft Modeler AddIn.

                               

                               

                               

                              I have attached a PDF of one of the medium complexity model diagrams, this is originated by VISO and each object has the data associated to drive AF configuration directly.   To give you a flavour of the tool (VisiBal) works I also attach a screenshot of how one page with an Tank Element highlighted appears (see file DrawingToolView.png)

                               

                               

                               

                              I realise OSIsoft have been very generous with your examples and time but it is above my pay grade to share our binaries with you at this stage, hence I have copied my directors on this so they are aware of our ongoing conversation.

                               

                               

                               

                              My timeline is now to deliver this commissioning phase by middle May, when I get back to the UK I will be able to pick up this C# development again.

                               

                              I would be pleased to keep you informed of progress after that

                               

                               

                               

                              Best Regards

                               

                              Rob Ferguson

                               

                              UKM : +44 (0)7767 317486

                               

                              UK : +44 (0)1330 830038

                               

                               

                                • Re: PROGRAMMATICALLY create AF Elements in a ProcessBook display using VBA.
                                  dng

                                  Hi Nigel,

                                   

                                  Thank you for providing detailed information.

                                   

                                  If you are developing in C#, you can potentially read your Visio structure with C#, and then use PI AF SDK directly to write to PI. PI AF SDK is a .NET library which integrates well with C#, and you don't have to worry about a wrapper anymore. Can you read the required Visio information with C# directly? If so, this could be a very good option for your project. For more information on working with Visio in C#, check out this MSDN article on Visio Solutions.


                                  I will be happy to assist when you pick up the project again!