Select features that intersect a geometry. This method must be called on the MCT. Use QueuedTask.Run.
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.
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();
});
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.