Private pEditLayers As ESRI.ArcGIS.Editor.IEditLayers = My.ArcMap.Editor Private pEditor As ESRI.ArcGIS.Editor.IEditor = My.ArcMap.Editor Private Sub SplitFeature(ByRef pfeature As ESRI.ArcGIS.Geodatabase.IFeature, ByRef pSplitPoints As ESRI.ArcGIS.Geometry.IPointCollection) Dim pEnumVertex As ESRI.ArcGIS.Geometry.IEnumVertex Dim pGeoColl As ESRI.ArcGIS.Geometry.IGeometryCollection Dim pPolyCurve As ESRI.ArcGIS.Geometry.IPolycurve2 Dim pEnumSplitPoint As ESRI.ArcGIS.Geometry.IEnumSplitPoint Dim pNewFeature As ESRI.ArcGIS.Geodatabase.IFeature Try pfeature.Shape.Project(pEditor.Map.SpatialReference) pEnumVertex = pSplitPoints.EnumVertices pPolyCurve = pfeature.Shape pEnumSplitPoint = pPolyCurve.SplitAtPoints(pEnumVertex, True, True, -1) If Not pEnumSplitPoint.SplitHappened Then Exit Sub pGeoColl = pPolyCurve pfeature.Shape = BuildPolyline(pGeoColl.Geometry(0)) pfeature.Store() For i As Integer = 1 To pGeoColl.GeometryCount - 1 pNewFeature = pEditLayers.CurrentLayer.FeatureClass.CreateFeature pNewFeature.Shape = BuildPolyline(pGeoColl.Geometry(i)) CopyAttributes(pfeature, pNewFeature) pNewFeature.Store() Next Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString, "SplitLine: SplitFeatures") End Try End Sub Private Function BuildPolyline(ByRef pSegColl As ESRI.ArcGIS.Geometry.ISegmentCollection) As ESRI.ArcGIS.Geometry.IPolyline Dim pPolyline As ESRI.ArcGIS.Geometry.IGeometryCollection = New ESRI.ArcGIS.Geometry.Polyline Dim pGeometry As ESRI.ArcGIS.Geometry.IGeometry Try pGeometry = pPolyline pGeometry.SpatialReference = pEditor.Map.SpatialReference pPolyline.AddGeometries(1, pSegColl) Return pPolyline Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString, "SplitLine: BuildPolyline") Return Nothing End Try End Function Private Sub CopyAttributes(ByRef pInFeature As ESRI.ArcGIS.Geodatabase.IFeature, ByRef pOutFeature As ESRI.ArcGIS.Geodatabase.IFeature) Dim pField As ESRI.ArcGIS.Geodatabase.IField Dim pFields As ESRI.ArcGIS.Geodatabase.IFields Try pFields = pInFeature.Fields For i As Integer = 0 To pFields.FieldCount - 1 pField = pFields.Field(i) If pField.Editable Then If Not pField.Type = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeOID And Not pField.Type = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry Then pOutFeature.Value(i) = pInFeature.Value(i) End If End If Next Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString, "SplitLine: CopyAttributes") End Try End Sub
Private Sub SplitFeature(ByRef pfeature As ESRI.ArcGIS.Geodatabase.IFeature, ByRef pSplitPoints As ESRI.ArcGIS.Geometry.IPointCollection) Dim pEnumVertex As ESRI.ArcGIS.Geometry.IEnumVertex Dim pPolyCurve As ESRI.ArcGIS.Geometry.IPolycurve2 Dim pEnumSplitPoint As ESRI.ArcGIS.Geometry.IEnumSplitPoint pEnumVertex = pSplitPoints.EnumVertices pPolyCurve = pfeature.Shape pEnumSplitPoint = pPolyCurve.SplitAtPoints(pEnumVertex, True, True, -1) 'You can check to see if the line was actually split if you need to do more things with the resultant polylines. 'If Not pEnumSplitPoint.SplitHappened Then Exit Sub End Sub
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.