code sample for splitting a line feature into two lines at a specified point.

2312
3
05-07-2012 12:20 PM
Highlighted
New Contributor
Hi All,

Could you point me to any C# code samples for splitting a polyline (IPolyline) into two at a specified point (with an IPoint reference)?


Thanks in advance!


George S.
Reply
0 Kudos
3 Replies
Highlighted
MVP Honored Contributor
It's a little old (and not in C#), but here's an example of splitting a line with points
Reply
0 Kudos
Highlighted
Esri Regular Contributor
For a simple line and point you can just use IFeatureEdit2.SplitWithUpdate to split the line and update the attributes.

IFeatureEdit2 featureEdit = lineFeature as IFeatureEdit2;
featureEdit.SplitWithUpdate(splitPoint);


Alternatively you can keep the returned ISet to do something useful, like keep all the lines selected in this example.
           
IFeatureEdit2 featureEdit = lineFeature as IFeatureEdit2;
//select features after split
featSelection.Add(lineFeature);
ISet newSet = featureEdit.SplitWithUpdate(splitPoint);
newSet.Reset();
IFeature newFeat = newSet.Next() as IFeature;
featSelection.Add(newFeat);
Reply
0 Kudos
Highlighted
New Contributor
thank you both!
Reply
0 Kudos