Interactive Selection Tolerance

Created:09/05/2002
Description:

The selection tolerance is used by the select features tool, select by graphics command, the edit tool and the identify tool to select features within the specified radius. It is set through the Selection Menu Options dialog.

This tip allows you to create a tool to interactively set the selection tolerance by draging a rubber circle on the ArcMap display. The radius of the circle is used to calculate the selection tolerance in pixels.


How to use:
  1. Create and edit a new UIToolControl (UIToolControl1) in ArcMap.
  2. Copy and paste the code into VBA.
  3. Close VBA and return to ArcMap.
  4. Place the new UIToolControl on a toolbar and apply it in ArcMap.
  5. Verify the selection tolerance has changed by showing the Selction Options dialog.
Private Function UIToolControl1_CursorID() As Variant
  UIToolControl1_CursorID = 3
End Function

Private Function UIToolControl1_Message() As String
  UIToolControl1_Message = "Sets the selection tolerance"
End Function

Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
  
  Dim pMxApp As IMxApplication
  Dim pMxDoc As IMxDocument
  
  Dim pCircArc As ICircularArc
  Dim pRubberCirc As IRubberBand
  
  Dim pMapPoint As WKSPoint
  Dim pDevPoint As tagPOINT
  Dim pDisplayTransformation As IDisplayTransformation
  
  Set pMxApp = Application
  Set pMxDoc = ThisDocument

  ' Create a new RubberCircle
  Set pRubberCirc = New RubberCircle
  ' Return a new CircularArc from the tracker object using TrackNew
  Set pCircArc = pRubberCirc.TrackNew(pMxDoc.ActiveView.ScreenDisplay, Nothing)
  
  'Convert radius to screen pixels
  Set pDisplayTransformation = pMxApp.Display.DisplayTransformation
  
  pMapPoint.x = pCircArc.Radius
  pMapPoint.y = pCircArc.Radius
  
  pDisplayTransformation.TransformCoords pMapPoint, pDevPoint, 1, 10
  
  'Set the search tolerance
  pMxDoc.SearchTolerancePixels = pDevPoint.x

End Sub

Private Function UIToolControl1_ToolTip() As String
  UIToolControl1_ToolTip = "Selection Tolerance"
End Function