ArcGIS Pro 3.7 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

In This Topic
    CreateEnvelope(Double,Double,Double,Double,SpatialReference) Method
    In This Topic
    Convenience method to create a new instance of the Envelope class.
    Syntax
    Public Overloads Shared Function CreateEnvelope( _
       ByVal xMin As Double, _
       ByVal yMin As Double, _
       ByVal xMax As Double, _
       ByVal yMax As Double, _
       Optional ByVal spatialReference As SpatialReference _
    ) As Envelope

    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 Rectangle Element
    {
      //Note: 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(
        layout, 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.
    
      //Note: Must be on QueuedTask.Run
    
      //Build 2D envelope geometry
      Coordinate2D rec_ll = new Coordinate2D(1.0, 4.75);
      Coordinate2D rec_ur = new Coordinate2D(3.0, 5.75);
    
      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);
    
    
      GraphicElement recElm = ElementFactory.Instance.CreateGraphicElement(
        layout, rec_env, polySym, "New Rectangle");
      //Or use Predefined shape
      GraphicElement recElm2 = ElementFactory.Instance.CreatePredefinedShapeGraphicElement(
                                layout, 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.
    
      //Note: Must be on 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";
    
      //use ElementInfo to set placement properties during create
      var elemInfo = new ElementInfo()
      {
        Anchor = Anchor.CenterPoint,
        Rotation = 45
      };
      var ptTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
        layout, TextType.PointText, coord2D.ToMapPoint(), sym, textString,
                           "New Point Text", true, elemInfo);
    
      //Change additional text properties
      ptTxtElm.SetX(4.5);
      ptTxtElm.SetY(9.5);
    }
    Create Map Frame and Set Camera
    {
      //Create a map frame and set its camera by zooming to the extent of an existing bookmark.
      //Construct on the worker thread
    
      //Build 2D envelope geometry
      Coordinate2D mf_ll = new Coordinate2D(6.0, 8.5);
      Coordinate2D mf_ur = new Coordinate2D(8.0, 10.5);
      Envelope mf_env = EnvelopeBuilderEx.CreateEnvelope(mf_ll, mf_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();
      Bookmark bookmark = mfMap.GetBookmarks().FirstOrDefault(
                            b => b.Name == "Great Lakes");
    
      MapFrame mfElm = ElementFactory.Instance.CreateMapFrameElement(
                           layout, mf_env, mfMap, "New Map Frame");
    
      //Zoom to bookmark
      mfElm.SetCamera(bookmark);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also