ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / GraphicFactory Class
Members Example

In This Topic
    GraphicFactory Class
    In This Topic
    Provides a mechanism for creating ArcGIS.Core.CIM.CIMGraphic. The CIMGraphic is typically used to create a GraphicElement
    Object Model
    GraphicFactory ClassCIMGraphic ClassCIMGraphic ClassCIMPictureGraphic ClassCIMPolygonGraphic ClassCIMGraphic ClassCIMTextGraphicBase ClassGeometry ClassGeometry ClassIGraphicFactory Interface
    Syntax
    public class GraphicFactory : IGraphicFactory  
    Public Class GraphicFactory 
       Implements IGraphicFactory 
    Example
    Create Graphic Element using CIMGraphic
    //on the QueuedTask
    //Place symbol on the layout
    //At 2.x - MapPoint location = MapPointBuilder.CreateMapPoint(
    //                                               new Coordinate2D(9, 1));
    MapPoint location = MapPointBuilderEx.CreateMapPoint(new Coordinate2D(9, 1));
    
    //specify a symbol
    var pt_symbol = SymbolFactory.Instance.ConstructPointSymbol(
                          ColorFactory.Instance.GreenRGB);
    
    //create a CIMGraphic 
    var graphic = new CIMPointGraphic()
    {
      Symbol = pt_symbol.MakeSymbolReference(),
      Location = location //center of map
    };
    //Or use GraphicFactory
    var graphic2 = GraphicFactory.Instance.CreateSimpleGraphic(location, pt_symbol);
    
    //At 2.x - LayoutElementFactory.Instance.CreateGraphicElement(layout, graphic);
    ElementFactory.Instance.CreateGraphicElement(container, graphic);
    ElementFactory.Instance.CreateGraphicElement(container, graphic2);
    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);
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Layouts.GraphicFactory

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also