AFLayer Class
- Last UpdatedNov 18, 2025
- 6 minute read
- PI System
- AF SDK 2024 R2
- Developer
A AFLayer provides a means within an AFModel
for organizing elements for presentation purposes and/or specifying active
elements when executing an analysis.

Inheritance Hierarchy
Namespace: OSIsoft.AF.Modeling
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
[SerializableAttribute] public sealed class AFLayer : AFObject, IComparable<AFLayer>
<SerializableAttribute> Public NotInheritable Class AFLayer Inherits AFObject Implements IComparable(Of AFLayer) Dim instance As AFLayer
[SerializableAttribute] public ref class AFLayer sealed : public AFObject, IComparable<AFLayer^>
[<SealedAttribute>] [<SerializableAttribute>] type AFLayer = class inherit AFObject interface IComparable<AFLayer> end
The AFLayer type exposes the following members.
Properties
| Name | Description | |
|---|---|---|
| Database |
This read-only property returns the AFDatabase where this object is defined.
| |
| Description |
Read/write property that provides a more detailed description of the object.
| |
| Elements |
This is a collection of elements for the layer representing all the
elements of the model that are associated with this layer.
| |
| ID |
Read-only property that provides a unique identifier for the object to be used for
quick access that is not dependent upon the index.
(Inherited from AFObject.) | |
| Identity |
This read-only property contains identity of the object.
(Inherited from AFObject.) | |
| IsDeleted |
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.) | |
| Model |
This read-only property is returns the AFModel that owns the layer.
| |
| Name |
Read/write property that identifies the name of the object.
| |
| PISystem |
This read-only property allows access to the PISystem associated with this
object.
(Inherited from AFObject.) | |
| UniqueID |
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.) |
Methods
| Name | Description | |
|---|---|---|
| CompareTo(Object) |
Compares this instance with a specified Object.
(Inherited from AFObject.) | |
| CompareTo(AFObject) |
Compares this instance with a specified AFObject.
(Inherited from AFObject.) | |
| Equals(Object) |
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.) | |
| Equals(AFObject) |
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.) | |
| 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 AFObject.) | |
| GetPath |
Returns the full path to the object, using just the names.
(Inherited from AFObject.) | |
| GetPath(AFObject) |
Returns the path to the object relative from another object.
(Inherited from AFObject.) | |
| GetPath(AFEncodeType, AFObject) |
Returns the path to the object relative from another object,
using the name and/or id as specified
by encodeType.
(Inherited from AFObject.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| Persist |
This method returns the persistence string for the object.
(Inherited from AFObject.) | |
| ToString |
Returns a String that represents the current object.
(Inherited from AFObject.) |
Remarks
The layer's AFElements collection keeps track of the elements which have been placed on the layer. An element is allowed to belong to multiple layers of a model.
Use the AFLayers.Add method of the AFModel.Layers collection to create a layer. Use the one of the AFElements.Add Overload methods of the AFLayer in order to add an element to a layer.
Examples
// This example demonstrates how to create a layer and add an element to it. // Get the Database PISystems myPISystems = new PISystems(); AFDatabase myDB = myPISystems.DefaultPISystem.Databases.DefaultDatabase; // Create an Element AFElement myElement = myDB.Elements.Add("MyElement"); // Create a Model AFElementTemplate modelTempl = myDB.ElementTemplates.Add("ModelTemplate"); modelTempl.InstanceType = typeof(AFModel); AFModel myModel = myDB.Elements.Add("MyModel", modelTempl) as AFModel; myDB.ApplyChanges(); // Add Elements to Model myModel.Elements.Add(myElement); // Create a Layer AFLayer myLayer = myModel.Layers.Add("MyLayer"); // Add an Element to a Layer myLayer.Elements.Add(myElement);
' This example demonstrates how to create a layer and add an element to it. ' Get the Database Dim myPISystems As New PISystems Dim myDB As AFDatabase = myPISystems.DefaultPISystem.Databases.DefaultDatabase ' Create an Element Dim myElement As AFElement = myDB.Elements.Add("MyElement") ' Create a Model Dim modelTempl As AFElementTemplate = myDB.ElementTemplates.Add("ModelTemplate") modelTempl.InstanceType = GetType(AFModel) Dim myModel As AFModel = CType(myDB.Elements.Add("MyModel", modelTempl), AFModel) myDB.ApplyChanges() ' Add Elements to Model myModel.Elements.Add(myElement) ' Create a Layer Dim myLayer As AFLayer = myModel.Layers.Add("MyLayer") ' Add an Element to a Layer myLayer.Elements.Add(myElement)
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.