Dim pSF As ISpatialFilter pSF.Geometry = pFeat.Shape pSF.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
Solved! Go to Solution.
pFeat = pFeatCur.NextFeature
While Not pFeat Is Nothing
'Select each feature in the layer. This feature will be used later to select other features that share a border with it.
pQF.WhereClause = "OBJECTID = " & pFeat.OID
Dim pSel As ISelectionSet = m_pFLay.FeatureClass.Select(pQF, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, pWorkspace)
strParam.Add(m_pFLay.Name)
strParam.Add("NEW_SELECTION")
strParam.Add(pQF.WhereClause)
'execute the select layer by attribute tool
Dim results2 As IGeoProcessorResult = CType(gp.Execute("SelectLayerByAttribute_Management", strParam, Nothing), IGeoProcessorResult)
If results2.Status <> ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded Then
MsgBox("Failed to execute select by attribute!", MsgBoxStyle.Information, "frmSelectLayer_btnRun_click")
results2 = Nothing
gp = Nothing
Exit Sub
End If
'now execute the select layer by location tool so we can select all features that share a border with each polygon in the layer
strParam.RemoveAll()
gp.OverwriteOutput = True
strParam.Add(m_pFLay.Name)
strParam.Add("SHARE_A_LINE_SEGMENT_WITH")
strParam.Add("")
strParam.Add("")
strParam.Add("NEW_SELECTION")
'execute the select layer by location tool
Dim results As IGeoProcessorResult = CType(gp.Execute("SelectLayerByLocation_Management", strParam, Nothing), IGeoProcessorResult)
If results.Status <> ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded Then
MsgBox("Failed to execute select by layer!", MsgBoxStyle.Information, "frmSelectLayer_btnRun_click")
results = Nothing
gp = Nothing
Exit Sub
End If
strParam.RemoveAll()
'now return the number of features that share a border, and populate the attribute table
Dim pFSel As IFeatureSelection = CType(m_pFLay, IFeatureSelection)
comReleaser.ManageLifetime(pFeat)
nCurRecNo = nCurRecNo + 1
Dim intFeatCount As Integer = pFSel.SelectionSet.Count
pFeat.Value(lFld) = intFeatCount
pFeatCur.UpdateFeature(pFeat)
My.ArcMap.Application.StatusBar.Message(0) = nCurRecNo.ToString & "/" & n.ToString & " records complete."
Me.ProgressBar1.Value = nCurRecNo
GC.Collect()
GC.WaitForPendingFinalizers()
Marshal.ReleaseComObject(pFeat)
pFeat = pFeatCur.NextFeature
Application.DoEvents()
End While