English

How To: Set the Select Feature and ID Results search tolerances to zero

Procedure

Summary

Scripts to enable the Select Feature and Identify Results tools to select only one feature at the time.

In ArcView 3.0a, if you clicked a single location, these tools would always select only one feature. In ArcView 3.1, these tools sometime select multiple features. This is due to changes to the operation of the Avenue request SelectbyPoint.

The SelectByPoint request was originally designed so that when sent it to an FTab object you could specify a distance tolerance in map units, but if you sent it to an FTheme object the distance tolerance was fixed at 3 screen pixels. However, the distance tolerance did not work as specified in either case and in actuality was fixed at a distance tolerance of zero. In ArcView 3.0a this led the Select Feature and Identify Results tools to only select one feature no matter how small the features or how far you were zoomed out. Starting in ArcView 3.1, this request now works as originally intended. Since this request is sent to an FTheme object in both tools, the search distance tolerance is now fixed at 3 screen pixels. This means that if you are zoomed out far enough, clicking one location may select multiple features instead of one. This is especially evident if you add a shapefile such as counties.shp (polygon) from the esridata/usa directory and keep the view zoomed to full extent. In the eastern half of the US, where the counties are very small on the screen display, clicking a single point may select 20-50 counties.

If you prefer the way these tools behaved in ArcView 3.0a, substitute the system scripts with the ones below and you will have the tools working as before. In the following scripts, the SelectByPoint feature is sent to an FTab rather than an FTheme object. This allows you to specify a distance tolerance. In these scripts the distance tolerance is set to zero.

Solution

For the Select Feature tool:

Copy this script into a script window, compile it, and rename the script document to View.SelectPoint. When you use the Select Feature tool, it will run this script rather than the system script.

Code:
'--- View.SelectPoint

theView = av.GetActiveDoc
r = theView.ReturnUserRect
theThemes = theView.GetActiveThemes
if (r.IsNull) then
p = theView.GetDisplay.ReturnUserPoint
if (System.IsShiftKeyDown) then
op = #VTAB_SELTYPE_XOR
else
op = #VTAB_SELTYPE_NEW
end
for each t in theThemes
f = t.getFTab
if (t.IsActive= true) then
f.SelectByPoint(p,0,op)
end
end
else
if (System.IsShiftKeyDown) then
op = #VTAB_SELTYPE_OR
else
op = #VTAB_SELTYPE_NEW
end
for each t in theThemes
if (t.CanSelect) then
t.SelectByRect(r, op)
end
end
end
av.GetProject.SetModified(true)

theView = av.GetActiveDoc
theTheme = theView.GetEditableTheme
if (theTheme = nil) then
theView.Select
else
theTheme.GetFTab.BeginTransaction
theTheme.Select
theTheme.GetFTab.EndTransaction
end
av.GetProject.SetModified(true)

'--- End of Script

For the Identify Results tool:

Copy this script into a script window, compile it, and name the script
View.Identify. This will cause the tool to return the attributes of only one
feature at a time.

Code:
'--- View.identify

theView = av.GetActiveDoc
found = FALSE
p = theView.GetDisplay.ReturnUserPoint
for each t in theView.GetActiveThemes
if (t.CanFindByPoint) then
thmClass = t.GetClass.GetClassName
scriptName = thmClass+".Identify"
if (av.FindScript(scriptName) <> nil) then
found = av.run(scriptName, {p,t,found})
else
'--Instead of FindByPoint, you can use SelectByPoint
'--keys = t.FindByPoint(p)
theFtab = t.GetFtab
theFtab.SelectByPoint(p, 0, #VTAB_SELTYPE_NEW)
keys = theFtab.GetSelection
for each key in keys
found = TRUE
idlabel = t.GetName++"-"
f = NIL
if (t.CanLabel) then
f = t.GetLabelField
end
if (f = NIL) then
if (key.Is(Number)) then
idlabel = idlabel++key.SetFormat("d").AsString
else
idlabel = idlabel++" X :"++key.GetX.AsString++" Y :"++key.GetY.AsString
end
else
s = t.ReturnValueString(f.GetName, key)
idlabel = idlabel++s
end
t.Identify(key, idlabel)
'--You can comment out the following line if you do NOT
'--want to clear the selection
t.ClearSelection
end
end
end
end
if (not found) then
System.Beep
end

'--- End of Script