ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.UtilityNetwork Namespace / UtilityNetwork Class / CreateElement Method / CreateElement(AssetType,Guid) Method
The AssetType of the row used to create the Element.
The global ID of the row used to create the Element.
Example

In This Topic
    CreateElement(AssetType,Guid) Method
    In This Topic
    Creates an Element object, which represents a Row (or Row + Terminal) in a utility network. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public Element CreateElement( 
       AssetType assetType,
       Guid globalID
    )
    Public Overloads Function CreateElement( _
       ByVal assetType As AssetType, _
       ByVal globalID As Guid _
    ) As Element

    Parameters

    assetType
    The AssetType of the row used to create the Element.
    globalID
    The global ID of the row used to create the Element.

    Return Value

    An Element object corresponding to globalID from a NetworkSource associated with assetType.
    Exceptions
    ExceptionDescription
    assetType is null.
    A geodatabase-related exception has occurred.
    This method or property must be called within the lambda passed to QueuedTask.Run
    Remarks
    No default Terminal is assigned. This overload allows the creation of a Element when no ArcGIS.Core.Data.Row is available. If you don't already have a Row object, fetching one requires an additional query (database query or round-trip call to the feature service). This constructor allows this extra call to be avoided.
    Example
    Create a utility network association
    // Create edit operation
    EditOperation editOperation = new EditOperation();
    editOperation.Name = "Create structural attachment association";
    
    // Create a RowHandle for the pole
    
    Element poleElement = utilityNetwork.CreateElement(poleAssetType, poleGlobalID);
    RowHandle poleRowHandle = new RowHandle(poleElement, utilityNetwork);
    
    // Create a RowHandle for the transformer bank
    
    Element transformerBankElement = utilityNetwork.CreateElement(transformerBankAssetType, transformerBankGlobalID);
    RowHandle transformerBankRowHandle = new RowHandle(transformerBankElement, utilityNetwork);
    
    // Attach the transformer bank to the pole
    
    AssociationDescription structuralAttachmentAssociationDescription = new AssociationDescription(AssociationType.Attachment, poleRowHandle, transformerBankRowHandle);
    editOperation.Create(structuralAttachmentAssociationDescription);
    editOperation.Execute();
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also