ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / MapFrame Class / GetViewExtent Method
Example

In This Topic
    GetViewExtent Method
    In This Topic
    Gets the current extent of the map frame view. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetViewExtent() As Envelope
    public Envelope GetViewExtent()

    Return Value

    ArcGIS.Core.Geometry.Envelope or null if the associated map is a scene
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    The associated map must be a 2D map or null is returned
    Example
    SetAutoCameraFixedExtent
    {
      var autoCamera = mapFrame.GetAutoCamera();
      autoCamera.Source = AutoCameraSource.Fixed;
      autoCamera.AutoCameraType = AutoCameraType.Extent;
    
      var mf_extent = mapFrame.GetViewExtent();
    
      var extent = EnvelopeBuilderEx.CreateEnvelope(
        400748.62, 800296.4, 1310669.05, 1424520.74, mapFrame.Map.SpatialReference);
      autoCamera.Extent = extent;
    
      if (mapFrame.ValidateAutoCamera(autoCamera) &&
        !mapFrame.IsMapSeriesMapFrame())
        mapFrame.SetAutoCamera(autoCamera);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also