AFAttribute Constructor (AFDatabase, String)
- Last UpdatedNov 18, 2025
- 3 minute read
- PI System
- AF SDK 2024 R2
- Developer
Namespace: OSIsoft.AF.Asset
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public AFAttribute( AFDatabase database, string path )
Public Sub New ( database As AFDatabase, path As String ) Dim database As AFDatabase Dim path As String Dim instance As New AFAttribute(database, path)
public: AFAttribute( AFDatabase^ database, String^ path )
new : database : AFDatabase * path : string -> AFAttribute
Parameters
- database
- Type: OSIsoft.AFAFDatabase
The AFDatabase associated with this new attribute. If , then the dynamically created attribute will not be associated with any AFDatabase. - path
- Type: SystemString
A string containing the dynamic attribute path used to specify the AFDataReference and its configuration. If , then the DataReferencePlugIn and ConfigString properties can be configured to obtain values using the DataReference. See the remarks section for a description of this parameter.
Remarks
The dynamically created AFAttribute is not associated with an AFBaseElement. If database is , then the dynamically created AFAttribute is not associated with any AFDatabase and the DefaultPISystem will be used to load the DataReferencePlugIn specified by the path. A dynamically created AFAttribute cannot be persisted to the server.
The AFDataReference is configured using the specified dynamic attribute path. The general format of the dynamic attribute path is the name of the AFDataReference, a period, followed by the data reference's ConfigString. For example a dynamic attribute with a simple PI Point configuration can be created with the following path: PI Point.\\YourPIServer\MilkTank1. Another example with a more complex PI Point configuration: PI Point.\\YourPIServer\MixMeter;TimeMethod=TimeRange;RelativeTime=-1h;TimeRangeMethod=Total.
Since dynamic attributes for PI Points are so common, you can leave off the data reference name and just provide the PI Point's ConfigString. The examples above can be simplified to the following: \\YourPIServer\MilkTank1 and \\YourPIServer\MixMeter;TimeMethod=TimeRange;RelativeTime=-1h;TimeRangeMethod=Total.
| A dynamically created attribute should not contain any substitution strings in its configuration that are relative references to the attribute. For example, %ELEMENT%, %\ELEMENTID%, and |%ATTRIBUTE% will all return an empty string. Also, %ATTRIBUTEID% will return the dynamically generated ID of the attribute and will probably not be the desired value. |
| If the specified path is a dynamic PIPoint path, this method will NOT validate that the PIPoint exists. The FindAttribute(String, AFObject) method with a path parameter will validate that the PIPoint exists. |