ArcGIS Pro 3.7 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 Function GetFeaturesForElements( _
       ByVal elements As IEnumerable(Of Element) _
    ) As IReadOnlyList(Of Selection)
    public IReadOnlyList<Selection> GetFeaturesForElements( 
       IEnumerable<Element> elements
    )

    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
    {
      // This routine demonstrates how to get a list of feature selections from a list of elements
      static 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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.3 or higher.
    See Also