ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Data.UtilityNetwork Namespace / UtilityNetwork Class / GetFeaturesForElements Method
The elements to get the selection.
Example

In This Topic
    GetFeaturesForElements Method
    In This Topic
    Gets a list of ObjectID based ArcGIS.Core.Data.Selection for corresponding input Element objects.
    Syntax
    public IReadOnlyList<Selection> GetFeaturesForElements( 
       IEnumerable<Element> elements
    )
    Public Function GetFeaturesForElements( _
       ByVal elements As IEnumerable(Of Element) _
    ) As IReadOnlyList(Of Selection)

    Parameters

    elements
    The elements to get the selection.

    Return Value

    A list of ArcGIS.Core.Data.Selection for the valid input Elements.
    Exceptions
    ExceptionDescription
    One or more of the input elements do not belong to the utility network.
    A geodatabase-related exception has occurred.
    Example
    Get selected features from a list of elements
        
    private void FeatureSelectionsFromTrace(UtilityNetwork utilityNetwork, TraceArgument traceArgument)
    {
      // Get the trace manager from the utility network
      using (TraceManager traceManager = utilityNetwork.GetTraceManager())
      {
        UpstreamTracer tracer = traceManager.GetTracer<UpstreamTracer>();
        IReadOnlyList<Result> tracerResults = tracer.Trace(traceArgument);
    
        foreach (Result traceResult in tracerResults)
        {
          if (traceResult is ElementResult elementResult)
          {
            IReadOnlyList<Element> elements = elementResult.Elements;
    
            // Feature selection from a list of elements
            IReadOnlyList<Selection> selections = utilityNetwork.GetFeaturesForElements(elements);
          }
        }
      }
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.3 or higher.
    See Also