Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFElements.Add Method (AFElement, AFReferenceType)

  • Last UpdatedNov 18, 2025
  • 3 minute read
AFElements.Add Method (AFElement, AFReferenceType)
This method adds an existing AFElement to the collection using the specified reference type.

Namespace:  OSIsoft.AF.Asset
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public void Add(
	AFElement item,
	AFReferenceType refType
)
Public Sub Add ( 
	item As AFElement,
	refType As AFReferenceType
)

Dim instance As AFElements
Dim item As AFElement
Dim refType As AFReferenceType

instance.Add(item, refType)
public:
void Add(
	AFElement^ item, 
	AFReferenceType^ refType
)
member Add : 
        item : AFElement * 
        refType : AFReferenceType -> unit 

Parameters

item
Type: OSIsoft.AF.AssetAFElement
An existing object to be added to the collection.
refType
Type: OSIsoft.AF.AssetAFReferenceType
The AFReferenceType specifies the hierarchical relationship between the inserted element and the element which own this collection of elements. The default reference type is the standard Parent-Child reference type. This parameter should not be specified when adding elements to a collection that does not represent a hierarchical relationship and are just references to elements within the hierarchy.

Remarks

An existing AFElement is added to this collection using the specified AFReferenceType. This allows the element to be in more than one hierarchical relationship.

Important note Important

There can only be a single hierarchical relationship between two elements. This means that you cannot insert an existing element into an elements collection that already contains that element.

Only one reference between the AFDatabase and an AFElement is allowed and its AFReferenceStrength must be Strong.

This method can also be used on the AFModel.Elements collection to add an existing AFElement object to the model. When first added to the model, the element is not connected to any other elements. Use one of the AFConnections.Add Overload methods to create a connection between two elements in the model.

When a reference is added to or removed from an element, the parent element is checked out in the client, but it is not actually checked out in the server. This allows elements to be added to or removed from the collection from multiple applications and then checked in without requiring a checkout lock on the parent element in the server. If any other change is made to the parent element, a full server checkout is performed. Calling ApplyChanges will also require a full server checkout to be performed before saving to the server.

Version Information

AFSDK


See Also

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in