ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryBagBuilderEx Class / AddGeometries Method
The list of geometries to add.
Example

In This Topic
    AddGeometries Method
    In This Topic
    Adds the given list of geometries to the end of the list of geometries in this GeometryBag.
    Syntax
    Public Sub AddGeometries( _
       ByVal geometries As IEnumerable(Of Geometry) _
    ) 
    public void AddGeometries( 
       IEnumerable<Geometry> geometries
    )

    Parameters

    geometries
    The list of geometries to add.
    Exceptions
    ExceptionDescription
    geometries is null.
    A geometry in geometries is null. You cannot insert a null geometry into a GeometryBag.
    A geometry in geometries is GeometryBag. You cannot insert a GeometryBag into another GeometryBag.
    Remarks
    An Envelope that is inserted into the builder is converted to a Polygon when the GeometryBag is created. As a result, when retrieving an Envelope from a GeometryBag, it will be a Polygon.
    Example
    Construct GeometryBag - adding or inserting an enumeration of geometries
    {
      MapPoint point = MapPointBuilderEx.CreateMapPoint(10, 20);
      List<Coordinate2D> coords = new List<Coordinate2D>() { new Coordinate2D(50, 60), new Coordinate2D(-120, -70), new Coordinate2D(40, 60) };
      Multipoint multipointNew = MultipointBuilderEx.CreateMultipoint(coords, SpatialReferences.WebMercator);
      Polyline polylineNew = PolylineBuilderEx.CreatePolyline(coords);
    
      string json = "{\"rings\":[[[0,0],[0,1],[1,1],[1,0],[0,0]],[[3,0],[3,1],[4,1],[4,0],[3,0]]]}";
      Polygon polygonNew = PolygonBuilderEx.FromJson(json);
    
      var geometries = new List<Geometry>() { point, multipoint, polyline, polygon };
    
      var builder = new GeometryBagBuilderEx(SpatialReferences.WGS84);
      builder.AddGeometries(geometries);
    
      GeometryBag geomBag = builder.ToGeometry();
      // geomBag.PartCount == 4    (point, multipoint, polyline, polygon)
    
      geometries = new List<Geometry>() { point, polyline };
      builder.InsertGeometries(1, geometries);
      // builder.GeometryCount == 6
      geomBag = builder.ToGeometry();
      // geomBag.PartCount == 6    (point, point, polyline, multipoint, polyline, polygon)
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also