SearchTolerance in ArcGIS Pro

338
7
06-25-2020 08:35 AM
KrisCulin
Occasional Contributor

Hi,

In ArcObjects, there is a SearchTolerance property on IMxDocument.

Is there an equivalent to this in the ArcGIS Pro SDK?  If so, where can I retrieve the value?

If not, what can I do to mimic what SearchTolerance does in ArcMap?  We use it with the Envelope.Expand method when detecting if a click point is near any existing features.

In ArcMap, SearchTolerance changes depending on the zoom.  The farther you zoom out, the larger the tolerance is and vice-versa.

TIA.

Kris

0 Kudos
7 Replies
UmaHarano
Esri Regular Contributor

In Pro, you can use the SelectionEnvironment class. 

SelectionTolerance

SetSelectionTolerance

Thanks!

Uma

0 Kudos
KrisCulin
Occasional Contributor

Thanks Uma.

Followup - the value is 3 and appears to be in Device Units which I assume is pixels.  How can I convert this value to the map linear unit so I can pass it into Envelope.Expand?  Is there an easy way to do this?  ArcObjects did this automatically with the SearchTolerance property (SearchTolerancePixels was the value in pixels).

TIA.

Kris

0 Kudos
SeanJones
Esri Regular Contributor

In the past ive calculated the pixel linear distance from a known point in the map, either the mouse location or the center of the map as a MapPoint.

    private Polygon CreateSearchPolygon(MapPoint mapPoint, int pixels)
    {
      //get search radius
      var screenPoint = MapView.Active.MapToScreen(mapPoint);
      var radiusScreenPoint = new System.Windows.Point((screenPoint.X + pixels), screenPoint.Y);
      var radiusMapPoint = MapView.Active.ScreenToMap(radiusScreenPoint);
      var searchRadius = GeometryEngine.Instance.Distance(mapPoint, radiusMapPoint);

In the example above i was creating a search polygon around a mappoint by pixels.

The variable searchRadius is your linear distance.

0 Kudos
KrisCulin
Occasional Contributor

Than you Sean.  This is exactly what I need.

Much appreciated.

Kris

0 Kudos
RobertGurrieri
New Contributor II

Hi Uma,

Is SelectionTolerance used by ArcGIS Pro itself (e.g. is it used by the native select tool)?  If so, can the tolerance setting be controlled by the user (is there an option in the UI somewhere)?

Thanks,

Rob.

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Robert,

I don't see an UI setting for Search Tolerance either.

Uma

0 Kudos
RobertGurrieri
New Contributor II

Thank you Uma.

Rob.

0 Kudos