Select to view content in your preferred language

SearchTolerance in ArcGIS Pro

1176
7
06-25-2020 08:35 AM
KrisCulin
Frequent 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
Frequent 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
by Anonymous User
Not applicable

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
Frequent Contributor

Than you Sean.  This is exactly what I need.

Much appreciated.

Kris

0 Kudos
RobertGurrieri
Emerging Contributor

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
Emerging Contributor

Thank you Uma.

Rob.

0 Kudos