ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / ElementFactory Class / CreateElement Method
Layout or GroupElement
The cimElement to be created
Select after create flag (default is true) (optional)
Example Version

CreateElement Method (ElementFactory)
Creates an element using the corresponding ArcGIS.Core.CIM.CIMElement definition. This method must be called on the MCT. Use QueuedTask.Run.
Syntax

Parameters

elementContainer
Layout or GroupElement
cimElement
The cimElement to be created
select
Select after create flag (default is true) (optional)

Return Value

Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Value cannot be null: cimElement
Use ElementFactory.CreateGroupElement(...) to create a group element.
Remarks
cimElement cannot be of type ArcGIS.Core.CIM.CIMGroupElement or a NotSupportedException will be thrown. Use CreateGroupElement
Example
Create Element using a CIMGraphicElement
//Must be on QueuedTask.Run(() => { ...

//Place symbol on the layout
//At 2.x - MapPoint point = MapPointBuilder.CreateMapPoint(new Coordinate2D(9, 1));
MapPoint point = MapPointBuilderEx.CreateMapPoint(new Coordinate2D(9, 1));

//specify a symbol
var pt_symbol = SymbolFactory.Instance.ConstructPointSymbol(
                      ColorFactory.Instance.GreenRGB);

//create a CIMGraphic 
var graphic = new CIMGraphicElement()
{
  Graphic = new CIMPointGraphic()
  {
    Symbol = pt_symbol.MakeSymbolReference(),
    Location = point //A point in the layout
  }
};
//At 2.x - LayoutElementFactory.Instance.CreateElement(layout, graphic);
ElementFactory.Instance.CreateElement(container, graphic);
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also