ArcGIS Pro 3.4 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 void AddGeometries( 
       IEnumerable<Geometry> geometries
    )
    Public Sub AddGeometries( _
       ByVal geometries As IEnumerable(Of Geometry) _
    ) 

    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 multipoint = MultipointBuilderEx.CreateMultipoint(coords, SpatialReferences.WebMercator);
    Polyline polyline = 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 polygon = PolygonBuilderEx.FromJson(json);
    
    var geometries = new List<Geometry>() { point, multipoint, polyline, polygon };
    
    //At 2.x - using (var builder = new GeometryBagBuilder(SpatialReferences.WGS84))
    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, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also