The following VB script is from http://forums.esri.com/Thread.asp?c=93&f=987&t=106536I tested it with a mxd containing a point file and a line file, the point file being first in the TOC. Do not run it in Edit mode. It works as long as the points are not at the beginning or end of the line as this results in lines of zero length.Sub SplitAll() Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument Dim pMap As IMap Set pMap = pMxDoc.FocusMap Dim pPointL As IFeatureLayer Set pPointL = pMap.Layer(0) 'point layer to split lines with Dim pLineL As IFeatureLayer Set pLineL = pMap.Layer(1) 'line layer to be split Dim pLineFC As IFeatureClass Set pLineFC = pLineL.FeatureClass Dim pPointFC As IFeatureClass Set pPointFC = pPointL.FeatureClass Dim pPointCursor As IFeatureCursor Set pPointCursor = pPointFC.Search(Nothing, False) Dim pPointF As IFeature Set pPointF = pPointCursor.NextFeature Do Until pPointF Is Nothing Dim pPoint As IPoint Set pPoint = pPointF.Shape Dim pSF As ISpatialFilter Set pSF = New SpatialFilter With pSF Set .Geometry = pPoint .GeometryField = "Shape" .SpatialRel = esriSpatialRelIntersects End With Dim pLineCursor As IFeatureCursor Set pLineCursor = pLineFC.Search(pSF, True) Dim pLineF As IFeature Set pLineF = pLineCursor.NextFeature Do Until pLineF Is Nothing Dim pPolyCurve As IPolycurve Set pPolyCurve = pLineF.Shape Dim pToPoint As IPoint Set pToPoint = pPolyCurve.ToPoint Dim pFromPoint As IPoint Set pFromPoint = pPolyCurve.FromPoint If (pFromPoint.X = pPoint.X And pFromPoint.Y = pPoint.Y) Then 'do nothing ElseIf (pToPoint.X = pPoint.X And pToPoint.Y = pPoint.Y) Then 'do nothing Else Dim pFeatureEdit As IFeatureEdit Set pFeatureEdit = pLineF pFeatureEdit.Split pPointF.Shape End If Set pLineF = pLineCursor.NextFeature Loop Set pPointF = pPointCursor.NextFeature Loop End Sub
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.