ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / IElementFactory Interface / CreateGraphicElements Method
The parent element container
The input graphic collection
Element names (optional)
Select after create flag (default is true) (optional)
Additional element properties (optional)
Example

In This Topic
    CreateGraphicElements Method (IElementFactory)
    In This Topic
    Create GraphicElement based on the input ArcGIS.Core.CIM.CIMGraphic collection and element properties.
    Syntax

    Parameters

    elementContainer
    The parent element container
    cimGraphics
    The input graphic collection
    elementNames
    Element names (optional)
    select
    Select after create flag (default is true) (optional)
    elementInfos
    Additional element properties (optional)

    Return Value

    Remarks
    The number of Element names and ElementInfos must either match the input number of CIMGraphics or be null. Refer to GraphicFactory for creating ArcGIS.Core.CIM.CIMGraphic
    Example
    Bulk Element creation
    //Must be on QueuedTask.Run(() => { ...
    
    //List of Point graphics
    var listGraphics = new List<CIMPointGraphic>();
    var listGraphics2 = new List<CIMPointGraphic>();
    //Symbol
    var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(
                                        ColorFactory.Instance.BlackRGB);
    //Define size of the array
    int dx = 5;
    int dy = 5;
    MapPoint point = null;
    //Create the List of graphics for the array
    for (int row = 0; row <= dx; ++row)
    {
      for (int col = 0; col <= dy; ++col)
      {
        //At 2.x - point = MapPointBuilder.CreateMapPoint(col, row);
        point = MapPointBuilderEx.CreateMapPoint(col, row);
        //create a CIMGraphic 
        var graphic = new CIMPointGraphic()
        {
          Symbol = pointSymbol.MakeSymbolReference(),
          Location = point
        };
        listGraphics.Add(graphic);
        //Or use GraphicFactory
        var graphic2 = GraphicFactory.Instance.CreateSimpleGraphic(
                                      point, pointSymbol) as CIMPointGraphic;
        listGraphics2.Add(graphic2);
      }
    }
    //Draw the array of graphics
    //At 2.x - var bulkgraphics =
    //              LayoutElementFactory.Instance.CreateGraphicElements(
    //                                              layout, listGraphics, null);
    
    var bulkgraphics = ElementFactory.Instance.CreateGraphicElements(
                                                       container, listGraphics);
    var bulkgraphics2 = ElementFactory.Instance.CreateGraphicElements(
                                                       container, listGraphics2);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also