Dim pSF As ISpatialFilter pSF.Geometry = pFeat.Shape pSF.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
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
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 pActView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) pMxDoc.CurrentContentsView.Refresh(Nothing) pMxDoc.ActiveView.Refresh() 'now execute the select layer by location tool 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() strParam.Add(m_pFLay.Name) Dim results3 As IGeoProcessorResult = CType(gp.Execute("GetCount_Management", strParam, Nothing), IGeoProcessorResult) 'MsgBox(results3) strParam.RemoveAll()
What results are you getting? Error message?
Dim pQF As IQueryFilter = New QueryFilter Dim pMxDoc As IMxDocument = My.ArcMap.Document Dim pActView As IActiveView = pMxDoc.ActiveView Dim gp As IGeoProcessor = New GeoProcessor Dim strParam As IVariantArray = New VarArray gp.OverwriteOutput = True strParam.Add(m_pFLay.Name) strParam.Add("SHARE_A_LINE_SEGMENT_WITH") pFeat = pFeatCur.NextFeature While Not pFeat Is Nothing '----------------test changes-------------------------------- pQF.WhereClause = "OBJECTID = " & pFeat.OID Dim pSel As ISelectionSet = m_pFLay.FeatureClass.Select(pQF, esriSelectionType.esriSelectionTypeSnapshot, esriSelectionOption.esriSelectionOptionNormal, pWorkspace) pMxDoc.CurrentContentsView.Refresh(Nothing) pActView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) '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 end while '-----------------end test changes----------------------------------------------
Dim gp As IGeoProcessor = New GeoProcessor Dim strParam As IVariantArray = New VarArray gp.OverwriteOutput = True strParam.Add(m_pFLay.Name) strParam.Add("SHARE_A_LINE_SEGMENT_WITH") '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
While Not pFeat Is Nothing comReleaser.ManageLifetime(pFeat) nNumAdjacent = 0 nCurRecNo = nCurRecNo + 1 'MsgBox(pFeat.OID) With pSpFltr .Geometry = pFeat.Shape 'EDGAR pPolygon .SpatialRel = esriSpatialRelEnum.esriSpatialRelTouches .OutputSpatialReference("Shape") = pSpRef 'm_pfc.Fields.Field(nShpFieldNDX).GeometryDef.SpatialReference .SubFields = "Shape" .GeometryField = "Shape" End With Dim intFeatCount As Integer = m_pfc.FeatureCount(pSpFltr) 'MsgBox(intFeatCount) pFeat.Value(lFld) = intFeatCount pFeatCur.UpdateFeature(pFeat) 'pFeat.Store() My.ArcMap.Application.StatusBar.Message(0) = nCurRecNo.ToString & "/" & n.ToString & " records complete." Me.ProgressBar1.Value = nCurRecNo ' GC.Collect() GC.WaitForPendingFinalizers() Marshal.ReleaseComObject(pFeat) 'comReleaser.ReleaseCOMObject(pFeat) pFeat = pFeatCur.NextFeature Application.DoEvents() End While
Dim gp As IGeoProcessor = New GeoProcessor Dim strParam As IVariantArray = New VarArray gp.OverwriteOutput = True gp.SetEnvironmentValue("Workspace", m_gdbPath) 'set the parameters for the select layer by location tool strParam.Add(pNewFLayer.Name) strParam.Add("SHARE_A_LINE_SEGMENT_WITH") '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 gp = Nothing
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.