3 Replies Latest reply on Sep 12, 2016 2:35 PM by Dava

    How can I check if an attribute exist in PI AF SDK

    Dava

      Well the title said it.
      is possible to check using the PI AF SDK if an attributte exist?@

        • Re: How can I check if an attribute exist in PI AF SDK
          pmartin

          Hi David,

           

          Is there any filtering you want to do to find your attribute?

          Do you want to search by name, by ID, in a particular part of  your hierarchy, in a particular element, etc?

           

          We have multiple methods depending on what you are looking to do.  Take a look at the static methods for the AFAttribute class.  Particularly the FindAttribute and FindElementAttributes methods should be helpful for you.

          • Re: How can I check if an attribute exist in PI AF SDK
            Marcos Vainer Loeff

            On top of what Paul has written, here is an example if you want to check if an attribute exists for a given AF path:

             

                    public static bool AttributeExists(string path)
                    {
                        AFAttribute attribute1 = AFObject.FindObject(path) as AFAttribute;
                        if (attribute1==null)
                        {
                            return false;
                        }
                        else
                        {
                            return true;
                        }
                    }
            

             

            Let us know if this is what you are looking for!

            3 of 3 people found this helpful