ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / IElementFactory Interface / CreateGraphicElement Method / CreateGraphicElement(IElementContainer,CIMGraphic,String,Boolean,ElementInfo) Method
The parent element container
The input graphic
Element name (optional)
Select after create flag (default is true) (optional)
Additional element properties (optional)
Example

In This Topic
    CreateGraphicElement(IElementContainer,CIMGraphic,String,Boolean,ElementInfo) Method
    In This Topic
    Create a GraphicElement based on the input ArcGIS.Core.CIM.CIMGraphic and element properties.
    Syntax
    Overloads Function CreateGraphicElement( _
       ByVal elementContainer As IElementContainer, _
       ByVal cimGraphic As CIMGraphic, _
       Optional ByVal elementName As String, _
       Optional ByVal select As Boolean, _
       Optional ByVal elementInfo As ElementInfo _
    ) As GraphicElement

    Parameters

    elementContainer
    The parent element container
    cimGraphic
    The input graphic
    elementName
    Element name (optional)
    select
    Select after create flag (default is true) (optional)
    elementInfo
    Additional element properties (optional)

    Return Value

    Remarks
    Example
    Create Graphic Element using CIMGraphic
    {
      //Note: on the QueuedTask
      //Place symbol on the layout
      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 graphicFactory = GraphicFactory.Instance.CreateSimpleGraphic(location, pt_symbol);
    
      ElementFactory.Instance.CreateGraphicElement(layout, graphic);
      ElementFactory.Instance.CreateGraphicElement(layout, graphicFactory);
    }
    Create Graphic Element using CIMSymbol
    {
      //Note: Must be on QueuedTask.Run
      //Place symbol on the layout
      MapPoint location = MapPointBuilderEx.CreateMapPoint(new Coordinate2D(9, 1));
    
      //specify a symbol
      var pt_symbol = SymbolFactory.Instance.ConstructPointSymbol(
                            ColorFactory.Instance.GreenRGB);
    
      ElementFactory.Instance.CreateGraphicElement(layout, location, pt_symbol);
    }
    Create Picture Graphic Element using CIMSymbol
    {
      //Note: Must be on QueuedTask.Run(() => { ...
    
      //Build geometry
      Coordinate2D ll = new Coordinate2D(0.5, 1);
      Coordinate2D ur = new Coordinate2D(2.5, 2);
      Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur);
    
      //Create and add element to layout
      string picPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
        "SamplePicture.jpg");
      var pic_gr = ElementFactory.Instance.CreatePictureGraphicElement(
        layout, env.Center, picPath, "New Picture", true, new ElementInfo() { Anchor = Anchor.CenterPoint });
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also