ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Geometry Namespace / MultipartBuilderEx Class / AddParts Method
An enumeration of parts built from an enumeration of segments.
Example

In This Topic
    AddParts Method
    In This Topic
    Adds the parts constructed from the set of enumeration of segments to the MultipartBuilderEx. The parts will be added to the end of the Parts list.
    Syntax

    Parameters

    parts
    An enumeration of parts built from an enumeration of segments.
    Exceptions
    ExceptionDescription
    parts is null.
    Remarks
    The spatial reference of each segment is ignored, and the attribute of each segment does not affect the attribute awareness of the builder. However, if the builder has an attribute and the start or end point of a segment 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
    Get the outermost rings of a polygon
    {
      List<Polygon> internalRings = new List<Polygon>();
    
      // explode the parts of the polygon into a list of individual geometries
      // see the "Get the individual parts of a multipart feature"
      // snippet for MultipartToSinglePart
      var parts = MultipartToSinglePart(polygon); //any polygon
    
      // get an enumeration of clockwise geometries (area > 0) ordered by the area
      var clockwiseParts = parts.Where(geom => ((Polygon)geom).Area > 0)
                            .OrderByDescending(geom => ((Polygon)geom).Area);
    
      // for each of the exterior rings
      foreach (var part in clockwiseParts)
      {
        // add the first (the largest) ring into the internal collection
        if (internalRings.Count == 0)
        {
          internalRings.Add(part as Polygon);
        }
    
        // use flag to indicate if current part is within the already selection polygons
        bool isWithin = false;
    
        foreach (var item in internalRings)
        {
          if (GeometryEngine.Instance.Within(part, item))
          {
            isWithin = true;
          }
        }
    
        // if the current polygon is not within any polygon of the internal collection
        // then it is disjoint and needs to be added to
        if (isWithin == false)
        {
          internalRings.Add(part as Polygon);
        }
      }
    
      PolygonBuilderEx outerRings = new PolygonBuilderEx();
      // now assemble a new polygon geometry based on the internal polygon collection
      foreach (var ring in internalRings)
      {
        outerRings.AddParts(ring.Parts);
      }
    
      // the final geometry of the outer rings
      var outerRingsResult = outerRings.ToGeometry();
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also