ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Geometry Namespace / MultipartBuilderEx Class / AddPart Method / AddPart(IEnumerable<Coordinate3D>) Method
An enumeration of coordinates.
Example

In This Topic
    AddPart(IEnumerable<Coordinate3D>) Method
    In This Topic
    Adds a part constructed by creating line segments from the enumeration of coordinates. The part will be added to the end of the Parts list.
    Syntax
    public void AddPart( 
       IEnumerable<Coordinate3D> coordinates
    )
    Public Overloads Sub AddPart( _
       ByVal coordinates As IEnumerable(Of Coordinate3D) _
    ) 

    Parameters

    coordinates
    An enumeration of coordinates.
    Exceptions
    ExceptionDescription
    coordinates is null.
    Remarks
    The HasZ property of the builder is set to true.
    Example
    Split multipart at point
    {
      // define a polyline
      MapPoint startPointZ = MapPointBuilderEx.CreateMapPoint(1, 1, 5);
      MapPoint endPointZ = MapPointBuilderEx.CreateMapPoint(20, 1, 5);
    
      Polyline polylineZ = PolylineBuilderEx.CreatePolyline([startPointZ, endPointZ]);
    
      // define a split point
      MapPoint splitPointAboveLine = MapPointBuilderEx.CreateMapPoint(10, 10, 10);
    
      // split the polyline at the point. Don't project the split point onto the line, don't create a new part
      var splitPolyline = GeometryEngine.Instance.SplitAtPoint(polylineZ, splitPointAboveLine, false, false, out bool splitOccurred, out int partIndex, out int segmentIndex);
    
      // splitOccurred = true
      // partIndex = 0
      // segmentIndex = 1
      // splitPolyline.PointCount = 3
      // splitPolyline.PartCount = 1
      // splitPolyline coordinates are (1, 1, 5), (10, 10, 10), (20, 1, 5)
    
      // split the polyline at the point.  dont project the split point onto the line, do create a new part
      splitPolyline = GeometryEngine.Instance.SplitAtPoint(polylineZ, splitPointAboveLine, false, false, out splitOccurred, out partIndex, out segmentIndex);
    
      // splitOccurred = true
      // partIndex = 1
      // segmentIndex = 0
      // splitPolyline.PointCount = 4
      // splitPolyline.PartCount = 2
      // splitPolyline first part coordinates are (1, 1, 5), (10, 10, 10)
      // splitPolyline second part coordinates are (10, 10, 10), (20, 1, 5)
    
      // split the polyline at the point.  do project the split point onto the line, don't create a new part
      splitPolyline = GeometryEngine.Instance.SplitAtPoint(polylineZ, splitPointAboveLine, false, false, out splitOccurred, out partIndex, out segmentIndex);
    
      // splitOccurred = true
      // partIndex = 0
      // segmentIndex = 1
      // splitPolyline.PointCount = 3
      // splitPolyline.PartCount = 1
      // splitPolyline coordinates are (1, 1, 5), (10, 10, 5), (20, 1, 5)
    
      // split the polyline at the point.  do project the split point onto the line, do create a new part
      splitPolyline = GeometryEngine.Instance.SplitAtPoint(polylineZ, splitPointAboveLine, false, false, out splitOccurred, out partIndex, out segmentIndex);
    
      // splitOccurred = true
      // partIndex = 1
      // segmentIndex = 0
      // splitPolyline.PointCount = 4
      // splitPolyline.PartCount = 2
      // splitPolyline first part coordinates are (1, 1, 5), (10, 10, 5)
      // splitPolyline second part coordinates are (10, 10, 5), (20, 1, 5)
    
      //
      // try to split with a point that won't split the line  - pt extends beyond the line
      //
    
      var pointAfterLine = MapPointBuilderEx.CreateMapPoint(50, 1, 10);
      splitPolyline = GeometryEngine.Instance.SplitAtPoint(polylineZ, pointAfterLine, false, false, out splitOccurred, out partIndex, out segmentIndex);
    
      // splitOccurred = false
      // ignore partIndex, sgementIndex
      // splitPolyline is the same as polylineZ
    
      ///
      ///  multipart polygon
      ///
      List<Coordinate3D> coordsZ =
      [
        new Coordinate3D(10,10,5),
      new Coordinate3D(10,20,5),
      new Coordinate3D(20,20,5),
      new Coordinate3D(20,10,5)
      ];
    
      List<Coordinate3D> coordsZ_2ndPart =
      [
        new Coordinate3D(30,20,10),
      new Coordinate3D(30,30,10),
      new Coordinate3D(35,28,10),
      new Coordinate3D(40,30,10),
      new Coordinate3D(40,20,10)
      ];
    
      var builder = new PolygonBuilderEx
      {
        HasZ = true
      };
      builder.AddPart(coordsZ);
      builder.AddPart(coordsZ_2ndPart);
    
      Polygon multipart = builder.ToGeometry();
    
      // pointA is closer to the first part of the multipart - the split occurs in the first part
      var pointA = MapPointBuilderEx.CreateMapPoint(22, 18, 7);
      var splitPolygon = GeometryEngine.Instance.SplitAtPoint(multipart, pointA, false, false, out splitOccurred, out partIndex, out segmentIndex);
    
      // splitPolygon.PointCount = 12
      // splitPolygon.PartCount = 2
      // splitPolygon first part coordinates  (10, 10, 5), (10, 20, 5), (20, 20, 5), (22, 18, 7), (20, 10, 5), (10, 10, 5)
    
      // pointB is midPoint between the 2 parts - no split will occur
      var pointB = MapPointBuilderEx.CreateMapPoint(25, 20, 7);
      splitPolygon = GeometryEngine.Instance.SplitAtPoint(multipart, pointB, true, false, out splitOccurred, out partIndex, out segmentIndex);
    
      // splitOccurred = false
      // ignore partIndex, sgementIndex
      // splitPolyline is the same as polylineZ
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also