AFAttributes Class
- Last UpdatedNov 18, 2025
- 9 minute read
- PI System
- AF SDK 2024 R2
- Developer

Inheritance Hierarchy
OSIsoft.AFAFCollection
OSIsoft.AFAFCollectionAFAttribute
OSIsoft.AFAFNamedCollectionAFAttribute
OSIsoft.AF.AssetAFAttributes
Namespace: OSIsoft.AF.Asset
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public sealed class AFAttributes : AFNamedCollection<AFAttribute>, IAFNamedCollection<IAFAttribute>, ICollection<IAFAttribute>, IEnumerable<IAFAttribute>, IEnumerable, IList<IAFAttribute>
Public NotInheritable Class AFAttributes Inherits AFNamedCollection(Of AFAttribute) Implements IAFNamedCollection(Of IAFAttribute), ICollection(Of IAFAttribute), IEnumerable(Of IAFAttribute), IEnumerable, IList(Of IAFAttribute) Dim instance As AFAttributes
public ref class AFAttributes sealed : public AFNamedCollection<AFAttribute^>, IAFNamedCollection<IAFAttribute^>, ICollection<IAFAttribute^>, IEnumerable<IAFAttribute^>, IEnumerable, IList<IAFAttribute^>
[<SealedAttribute>] type AFAttributes = class inherit AFNamedCollection<AFAttribute> interface IAFNamedCollection<IAFAttribute> interface ICollection<IAFAttribute> interface IEnumerable<IAFAttribute> interface IEnumerable interface IList<IAFAttribute> end
The AFAttributes type exposes the following members.
Properties
| Name | Description | |
|---|---|---|
| Count |
Gets the number of items actually contained in the collection.
(Inherited from AFCollectionT.) | |
| Database |
This read-only property returns the AFDatabase where this object is defined.
| |
| Element |
This property returns the AFBaseElement object which owns the
attribute collection.
| |
| Identity |
This read-only property contains identity of the object.
(Inherited from AFCollection.) | |
| IsDeleted |
This read-only property indicates whether the owner of the collection has been deleted.
(Inherited from AFCollection.) | |
| ItemGuid | Returns the item in the collection associated with the passed in ID. (Inherited from AFCollectionT.) | |
| ItemInt32 | Returns the item located at the passed in index. (Inherited from AFCollectionT.) | |
| ItemString |
Returns the specified object from the collection by name.
(Inherited from AFNamedCollectionT.) | |
| ItemIdentity |
This read-only property specifies the identity of the objects within the collection.
(Inherited from AFCollection.) | |
| Parent |
This read-only property returns the AFAttribute that owns this collection of
attributes.
| |
| PISystem |
This read-only property allows access to the PISystem
associated with this collection.
(Inherited from AFCollection.) |
Methods
| Name | Description | |
|---|---|---|
| Add(T) |
Adds an object to the end of the collection.
(Inherited from AFCollectionT.) | |
| Add(String) |
The Add method creates a new object and adds it to the collection.
| |
| Clear |
Removes all items from the collection.
(Inherited from AFCollectionT.) | |
| Contains(Guid) |
This method determines whether the collection contains a specific item referenced by id.
(Inherited from AFCollectionT.) | |
| Contains(T) |
This method determines whether the collection contains a specific item.
(Inherited from AFCollectionT.) | |
| Contains(String) |
This method determines whether the collection contains a specific item referenced by name.
(Inherited from AFNamedCollectionT.) | |
| CopyTo |
Copies the entire collection to a compatible one-dimensional Array,
starting at the specified index of the target array.
(Inherited from AFCollectionT.) | |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
| GetEnumerator |
Returns an enumerator that iterates through the collection.
(Inherited from AFCollectionT.) | |
| GetHashCode |
Gets the hash code for this instance of the object which is suitable for use in hashing
algorithms and data structures like a hash table.
(Inherited from AFCollection.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| GetValue |
This method gets the value for each attribute in the list based upon its data
reference configuration.
| |
| GetValue(AFCase) |
This method gets the value for each attribute in the list based upon its data
reference configuration and the specified AFCase context.
| |
| GetValue(AFTime) |
This method gets the value for each attribute in the list based upon its data
reference configuration and the specified AFTime context.
| |
| GetValue(AFTimeRange) |
This method gets the value for each attribute in the list based upon its data
reference configuration and the specified AFTimeRange context.
| |
| IndexOf |
Searches for the specified object and returns the zero-based index of the first
occurrence within the entire collection.
(Inherited from AFCollectionT.) | |
| Remove(Guid) |
Removes the item with the specified id from the collection.
(Inherited from AFCollectionT.) | |
| Remove(T) |
Removes the first occurrence of a specific object from the collection.
(Inherited from AFCollectionT.) | |
| Remove(String) |
The Remove method removes the item from the collection by name.
(Inherited from AFNamedCollectionT.) | |
| RemoveAt |
Removes the item at the specified index of the collection.
(Inherited from AFCollectionT.) | |
| Sort |
Sorts the items in the entire collection using the default comparer.
(Inherited from AFCollectionT.) | |
| Sort(IComparerT) |
Sorts the items in the entire collection using the specified comparer.
(Inherited from AFCollectionT.) | |
| Sort(Int32, Int32, IComparerT) |
Sorts the items in a range of items in the collection using the specified comparer.
(Inherited from AFCollectionT.) | |
| ToString |
Returns a String that represents the current object.
(Inherited from AFCollection.) |
Extension Methods
| Name | Description | |
|---|---|---|
| ChunkedByIAFAttribute |
This extension method breaks up search results into chunks to make it easier to
page through and process IEnumerableT collections in chunks.
(Defined by AFSDKExtension.) |
Remarks
Each of the following types derived from AFBaseElement contain a collection of attributes: AFElement, AFModel, AFEventFrame, AFTransfer, AFCase, and AFNotification. An AFAttribute object also has an AFAttributes collection which allows the creation of a hierarchy of attributes within the element.
The set of attributes for an element is a combination of those created from the template, and if allowed by the AllowElementToExtend setting, those added individually to the element. The template based attributes are created from the collection of AFAttributeTemplates in the AFElementTemplate that is used to create the element. An attribute is created for all attribute templates defined by the template plus any additional attribute templates defined by the base templates.
When using the ItemString collection indexer to find an attribute by string, you can use a name like most other collections or a path to an attribute. When using a path, it is normally relative to the owning element or parent attribute, but can be a full path to any attribute. For example, the following are valid when looking up an attribute by path:
- MyParentAttribute["Child1|Child2"]
- MyParentAttribute["..|OtherAttribute|ChildAttribute"]
- MyParentAttribute["\\MySystem\MyDatabase\OtherElement|OtherAttribute|ChildAttribute"]
To create a list of unrelated attributes, use the AFAttributeList collection.
Examples
// This example demonstrates how to create an attribute for an // element and display information about it. // Get the Database PISystems myPISystems = new PISystems(); PISystem myPISystem = myPISystems.DefaultPISystem; AFDatabase myDB = myPISystem.Databases.DefaultDatabase; // Create an Element AFElement myElement = myDB.Elements.Add("MyElement"); // Create an Attribute AFAttribute myAttribute = myElement.Attributes.Add("MyAttribute"); myAttribute.Description = "Attribute for MyElement"; myAttribute.DefaultUOM = myPISystem.UOMDatabase.UOMs["kelvin"]; myAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem); // An example of a valid configuration string: // "\\%Server%\sinusoid;ptclassname=classic;pointtype=Float32;pointsource=R;descriptor=""12 Hour Sine Wave"";location2=2;location4=1" myAttribute.ConfigString = myConfigString; // Get Value AFValue myValue = myAttribute.GetValue(myPISystem.UOMDatabase.UOMs["degree Celsius"]); Console.WriteLine("Attribute Template Value = {0} {1}", myValue.Value, myValue.UOM); // Display Attribute Information foreach (AFAttribute CurAttribute in myElement.Attributes) { Console.WriteLine("Name of Attribute = {0}", CurAttribute.Name); Console.WriteLine("Description = {0}", CurAttribute.Description); Console.WriteLine("Default UOM = {0}", CurAttribute.DefaultUOM.Name); Console.WriteLine("DataReference = {0}", CurAttribute.DataReference.Name); Console.WriteLine("ConfigString = {0}", CurAttribute.ConfigString); }
' This example demonstrates how to create an attribute for an ' element and display information about it. ' Get the Database Dim myPISystems As New PISystems Dim myPISystem As PISystem = myPISystems.DefaultPISystem Dim myDB As AFDatabase = myPISystem.Databases.DefaultDatabase ' Create An Element Dim myElement As AFElement = myDB.Elements.Add("MyElement*") ' Create an Attribute Dim CurAttribute As AFAttribute = myElement.Attributes.Add("MyAttribute") CurAttribute.Description = "Attribute for MyElement" CurAttribute.DefaultUOM = myPISystem.UOMDatabase.UOMs("Kelvin") CurAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem) ' An example of a valid configuration string ' "\\%Server%\sinusoid;ptclassname=classic;pointtype=Float32;pointsource=R;descriptor=""12 Hour Sine Wave"";location2=2;location4=1" CurAttribute.ConfigString = myConfigString 'Get Value Dim myValue As AFValue = CurAttribute.GetValue(myPISystem.UOMDatabase.UOMs("degree Celsius")) Console.WriteLine("Attribute Template Value = {0} {1}", myValue.Value, myValue.UOM) ' Display Attribute Information For Each CurAttribute In myElement.Attributes Console.WriteLine("Name of Attribute = {0}", CurAttribute.Name) Console.WriteLine("Description = {0}", CurAttribute.Description) Console.WriteLine("Default UOM = {0}", CurAttribute.DefaultUOM.Name) Console.WriteLine("DataReference = {0}", CurAttribute.DataReference.Name) Console.WriteLine("ConfigString = {0}", CurAttribute.ConfigString) Next CurAttribute
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.