ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / EnvelopeBuilderEx Class / CreateEnvelope Method / CreateEnvelope(Double,Double,Double,Double,SpatialReference) Method
Minimum X value of the envelope.
Minimum Y value of the envelope.
Maximum X value of the envelope.
Maximum Y value of the envelope.
(Optional) The SpatialReference. The default value is null.
Example Version

CreateEnvelope(Double,Double,Double,Double,SpatialReference) Method
Convenience method to create a new instance of the Envelope class.
Syntax

Parameters

xMin
Minimum X value of the envelope.
yMin
Minimum Y value of the envelope.
xMax
Maximum X value of the envelope.
yMax
Maximum Y value of the envelope.
spatialReference
(Optional) The SpatialReference. The default value is null.

Return Value

Remarks
The resulting envelope is normalized to ensure its XMin <= XMax, YMin <= YMax. If any of the xy-coordinate values are NaN, then the envelope is set to empty.
Example
Union two Envelopes
// use the convenience builders
Envelope env1 = EnvelopeBuilderEx.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84);
Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84);

Envelope env3 = env1.Union(env2);

double area = env3.Area;
double depth = env3.Depth;
double height = env3.Height;
double width = env3.Width;
double len = env3.Length;

MapPoint centerPt = env3.Center;
Coordinate2D coord = env3.CenterCoordinate;

bool isEmpty = env3.IsEmpty;
int pointCount = env3.PointCount;

// coordinates
//env3.XMin, env3.XMax, env3.YMin, env3.YMax
//env3.ZMin, env3.ZMax, env3.MMin, env3.MMax

bool isEqual = env1.IsEqual(env2);    // false

// or use the builderEx constructors which don't need to run on the MCT.
EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(0, 0, 1, 1, SpatialReferences.WGS84);
builderEx.Union(env2);      // builder is updated to the result

depth = builderEx.Depth;
height = builderEx.Height;
width = builderEx.Width;

centerPt = builderEx.Center;
coord = builderEx.CenterCoordinate;

isEmpty = builderEx.IsEmpty;

env3 = builderEx.ToGeometry() as Envelope;
Create_polygon_env
//Create a polygon graphic using an envelope with simple line and fill styles.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build 2D envelope
  Coordinate2D env_ll = new Coordinate2D(1.0, 4.75);
  Coordinate2D env_ur = new Coordinate2D(3.0, 5.75);
  //At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(env_ll, env_ur);
  Envelope env = EnvelopeBuilderEx.CreateEnvelope(env_ll, env_ur);

  //Set symbolology, create and add element to layout
  CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
    ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.DashDotDot);
  CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(
    ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline);
  //At 2.x - GraphicElement polyElm =
  //            LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, env, polySym);
  //         polyElm.SetName("New Polygon");
  GraphicElement polyElm = ElementFactory.Instance.CreateGraphicElement(
    layout, env, polySym, "New Polygon");
});
Create_MapFrame
//Creates a new map frame and changes the camera's scale.

//Constuct on the worker thread
await QueuedTask.Run(() =>
{
  //Build geometry
  Coordinate2D ll = new Coordinate2D(6.0, 8.5);
  Coordinate2D ur = new Coordinate2D(8.0, 10.5);
  //At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(ll, ur);
  Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur);

  //Reference map, create MF and add to layout
  MapProjectItem mapPrjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map"));
  Map mfMap = mapPrjItem.GetMap();
  //At 2.x - mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, env, mfMap);
  //         mfElm.SetName("New Map Frame"); 
  mfElm = ElementFactory.Instance.CreateMapFrameElement(layout, env, mfMap, "New Map Frame");

  //Set the camera
  Camera camera = mfElm.Camera;
  camera.Scale = 24000;
  mfElm.SetCamera(camera);
});
Create Rectangle Element
//Must be on QueuedTask.Run(() => { ...

//Build geometry
Coordinate2D ll = new Coordinate2D(1.0, 4.75);
Coordinate2D ur = new Coordinate2D(3.0, 5.75);
Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur);

//Set symbology, create and add element to layout
CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
  ColorFactory.Instance.BlackRGB, 5.0, SimpleLineStyle.Solid);
CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(
  ColorFactory.Instance.GreenRGB, SimpleFillStyle.DiagonalCross, outline);

var ge = GraphicFactory.Instance.CreateSimpleGraphic(env, polySym);
var elemInfo = new ElementInfo()
{
  Anchor = Anchor.CenterPoint,
  Rotation = 45.0,
  CornerRounding = 5.0
};

ElementFactory.Instance.CreateGraphicElement(
  container, env, polySym, "New Rectangle", false, elemInfo);
Create rectangle graphic with simple symbology
//Create a simple 2D rectangle graphic and apply simple fill and
//outline symbols.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build 2D envelope geometry
  Coordinate2D rec_ll = new Coordinate2D(1.0, 4.75);
  Coordinate2D rec_ur = new Coordinate2D(3.0, 5.75);
  //At 2.x - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur);
  Envelope rec_env = EnvelopeBuilderEx.CreateEnvelope(rec_ll, rec_ur);

  //Set symbology, create and add element to layout
  CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
    ColorFactory.Instance.BlackRGB, 5.0, SimpleLineStyle.Solid);
  CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(
    ColorFactory.Instance.GreenRGB, SimpleFillStyle.DiagonalCross, outline);

  //At 2.x - GraphicElement recElm =
  //           LayoutElementFactory.Instance.CreateRectangleGraphicElement(
  //                                                  layout, rec_env, polySym);
  //         recElm.SetName("New Rectangle");
  //
  GraphicElement recElm = ElementFactory.Instance.CreateGraphicElement(
    container, rec_env, polySym, "New Rectangle");
  //Or use Predefined shape
  GraphicElement recElm2 = ElementFactory.Instance.CreatePredefinedShapeGraphicElement(
                            container, PredefinedShape.Rectangle, rec_env, polySym, 
                            "New Rectangle2");
});
Create Point Text Element 1
//Create a simple point text element and assign basic symbology and text settings.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build 2D point geometry
  Coordinate2D coord2D = new Coordinate2D(3.5, 10);

  //Set symbology, create and add element to layout
  CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
                ColorFactory.Instance.RedRGB, 32, "Arial", "Regular");
  string textString = "Point text";
  //At 2.x - GraphicElement ptTxtElm =
  //         LayoutElementFactory.Instance.CreatePointTextGraphicElement(
  //                           layout, coord2D, textString, sym);
  //ptTxtElm.SetName("New Point Text");
  //ptTxtElm.SetAnchor(Anchor.CenterPoint);
  //ptTxtElm.SetX(4.5);
  //ptTxtElm.SetY(9.5);
  //ptTxtElm.SetRotation(45);

  //use ElementInfo to set placement properties during create
  var elemInfo = new ElementInfo()
  {
    Anchor = Anchor.CenterPoint,
    Rotation = 45
  };
  var ptTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
    container, TextType.PointText, coord2D.ToMapPoint(), sym, textString,
                       "New Point Text", true, elemInfo);

  //Change additional text properties
  ptTxtElm.SetX(4.5);
  ptTxtElm.SetY(9.5);
});
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also