ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / SelectFeaturesEx Method
The geometry used to select features that intersect it.
Combination method used in selection operation.
This parameter only applies to 3D. Indicates whether only features that visibly intersect the geometry should be selected.
This parameter only applies to 2D. Indicates whether only features that are completely within the geometry should be selected.
Example

In This Topic
    SelectFeaturesEx Method
    In This Topic
    Select features that intersect a geometry. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function SelectFeaturesEx( _
       ByVal geometry As Geometry, _
       Optional ByVal method As SelectionCombinationMethod, _
       Optional ByVal isVisualIntersect As Boolean, _
       Optional ByVal isWhollyWithin As Boolean _
    ) As SelectionSet

    Parameters

    geometry
    The geometry used to select features that intersect it.
    method
    Combination method used in selection operation.
    isVisualIntersect
    This parameter only applies to 3D. Indicates whether only features that visibly intersect the geometry should be selected.
    isWhollyWithin
    This parameter only applies to 2D. Indicates whether only features that are completely within the geometry should be selected.

    Return Value

    The map selection created by the intersection with the geometry.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    3D views only support selecting features interactively using geometry in screen coordinates relative to the top-left corner of the view.
    Example
    Select features via the MapView
    //assume the geometry used in SelectFeaturesEx() is coming from a 
    //map tool...
    //
    //SketchType = SketchGeometryType.Rectangle;
    //SketchOutputMode = SketchOutputMode.Screen;
    
    await QueuedTask.Run(() =>
    {
      var result = MapView.Active.SelectFeaturesEx(geometry);
      //Get scene layers with selections
      //At 2.x - var scene_layers = result.Where(kvp => kvp.Key is FeatureSceneLayer);
      var scene_layers = result.ToDictionary<FeatureSceneLayer>();
      foreach (var kvp in scene_layers)
      {
        var scene_layer = kvp.Key as FeatureSceneLayer;
        var sel_oids = kvp.Value;
        //If there are attributes then get them
        if (scene_layer.HasAssociatedFeatureService)
        {
          var insp = new Inspector();
          foreach (var oid in sel_oids)
          {
            insp.Load(scene_layer, oid);
            //TODO something with retrieved attributes
          } 
        }
      }
    });
     
    Use MapView Selection SelectFeaturesEx or GetFeaturesEx
    //var featSceneLayer = ...;
    var sname = featSceneLayer.Name;
    
    await QueuedTask.Run(() =>
    {
      //Select all features within the current map view
      var sz = MapView.Active.GetViewSize();
    
      var c_ll = new Coordinate2D(0, 0);
      var c_ur = new Coordinate2D(sz.Width, sz.Height);
      //Use screen coordinates for 3D selection on MapView
      var env = EnvelopeBuilderEx.CreateEnvelope(c_ll, c_ur);
    
      //HasAssociatedFeatureService does not matter for SelectFeaturesEx
      //or GetFeaturesEx
      var result = MapView.Active.SelectFeaturesEx(env);
      //var result = MapView.Active.GetFeaturesEx(env);
    
      //The list of object ids from SelectFeaturesEx
      //At 2.x - var oids1 = result.Where(kvp => kvp.Key.Name == sname).First().Value;
      var oids1 = result.ToDictionary().Where(kvp => kvp.Key.Name == sname).First().Value;
      //TODO - use the object ids
    
      MapView.Active.Map.ClearSelection();
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also