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

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

    Parameters

    points
    An enumeration of points.
    Exceptions
    ExceptionDescription
    points is null.
    Remarks
    The spatial reference of each point is ignored. The attribute of each point does not affect the attribute awareness of the builder. However, if the builder has an attribute and a point also has that attribute, then the attribute value will be taken from the point. If the point doesn't have that attribute, then a default value will be set in the builder. For example, suppose the HasZ property of the builder is set to true. If the HasZ property of a point is set to true, then the point's Z-value is used. Otherwise, the default value is used. The default value for Z is 0, for M is NaN and for ID is 0.
    Example
    Build a multi-part Polyline
    {
      List<MapPoint> firstPoints = new List<MapPoint>();
      firstPoints.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0));
      firstPoints.Add(MapPointBuilderEx.CreateMapPoint(1.0, 2.0));
      firstPoints.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0));
      firstPoints.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0));
    
      List<MapPoint> nextPoints = new List<MapPoint>();
      nextPoints.Add(MapPointBuilderEx.CreateMapPoint(11.0, 1.0));
      nextPoints.Add(MapPointBuilderEx.CreateMapPoint(11.0, 2.0));
      nextPoints.Add(MapPointBuilderEx.CreateMapPoint(12.0, 2.0));
      nextPoints.Add(MapPointBuilderEx.CreateMapPoint(12.0, 1.0));
    
      // use AttributeFlags.None since we have 2D points in the list
      PolylineBuilderEx pBuilder = new PolylineBuilderEx(firstPoints, AttributeFlags.None);
      pBuilder.AddPart(nextPoints);
    
      Polyline polylineFromBuilder = pBuilder.ToGeometry();
      // polyline has 2 parts
    
      pBuilder.RemovePart(0);
      polylineFromBuilder = pBuilder.ToGeometry();
      // polyline has 1 part
    }
    Split Polyline at distance
    {
      // create list of points
      MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0);
      MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0);
    
      List<MapPoint> list = new List<MapPoint>() { startPt, endPt };
    
      // BuilderEx constructors don't need to run on the MCT.
    
      // use the PolylineBuilder as we wish to manipulate the geometry
      // use AttributeFlags.None as we have 2D points
      PolylineBuilderEx polylineBuilder = new PolylineBuilderEx(list, AttributeFlags.None);
      // split at a distance 0.75
      polylineBuilder.SplitAtDistance(0.75, false);
      // get the polyline
      Polyline polylineFromBuilder = polylineBuilder.ToGeometry();
      // polyline should have 3 points  (1,1), (1.75, 1), (2,1)
    
      // add another path
      MapPoint p1 = MapPointBuilderEx.CreateMapPoint(4.0, 1.0);
      MapPoint p2 = MapPointBuilderEx.CreateMapPoint(6.0, 1.0);
      MapPoint p3 = MapPointBuilderEx.CreateMapPoint(7.0, 1.0);
      List<MapPoint> pts = new List<MapPoint>() { p1, p2, p3 };
    
      polylineBuilder.AddPart(pts);
      polylineFromBuilder = polylineBuilder.ToGeometry();
    
      // polyline has 2 parts. Each part has 3 points
    
      // split the 2nd path half way - don't create a new path
      polylineBuilder.SplitPartAtDistance(1, 0.5, true, false);
    
      polylineFromBuilder = polylineBuilder.ToGeometry();
    
      // polyline still has 2 parts; but now has 7 points
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also