ArcObjects Library Reference

Cut Polygon Snippet

Use a polyline to cut a polygon.

[C#]

///<summary>Use a polyline to cut a polygon.</summary>
///  
///<param name="polygon">An IPolygon interface that is the polygon to be split.</param>
///<param name="polyline">An IPolyline interface that is used to cut the input polygon.</param>
///   
///<returns>An IGeometryCollection with polygons resulting from the split.</returns>
///   
///<remarks></remarks>
public ESRI.ArcGIS.Geometry.IGeometryCollection CutPolygon(ESRI.ArcGIS.Geometry.IPolygon polygon, ESRI.ArcGIS.Geometry.IPolyline polyline)
{
  if(polygon == null || polyline == null)
  {
    return null;
  }
  ESRI.ArcGIS.Geometry.ITopologicalOperator4 topologicalOperator4 = polygon as ESRI.ArcGIS.Geometry.ITopologicalOperator4; // Dynamic Cast
  ESRI.ArcGIS.Geometry.IGeometryCollection geometryCollection = topologicalOperator4.Cut2(polyline);

  return geometryCollection;
}
[Visual Basic .NET]

'''<summary>Use a polyline to cut a polygon.</summary>
'''  
'''<param name="polygon">An IPolygon interface that is the polygon to be split.</param>
'''<param name="polyline">An IPolyline interface that is used to cut the input polygon.</param>
'''   
'''<returns>An IGeometryCollection with polygons resulting from the split.</returns>
'''   
'''<remarks></remarks>
Public Function CutPolygon(ByVal polygon As ESRI.ArcGIS.Geometry.IPolygon, ByVal polyline As ESRI.ArcGIS.Geometry.IPolyline) As ESRI.ArcGIS.Geometry.IGeometryCollection

  If polygon Is Nothing OrElse polyline Is Nothing Then
    Return Nothing
  End If

  Dim topologicalOperator4 As ESRI.ArcGIS.Geometry.ITopologicalOperator4 = TryCast(polygon, ESRI.ArcGIS.Geometry.ITopologicalOperator4) ' Dynamic Cast
  Dim geometryCollection As ESRI.ArcGIS.Geometry.IGeometryCollection = topologicalOperator4.Cut2(polyline)

  Return geometryCollection

End Function


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Geometry
  • ESRI.ArcGIS.System