How do I modify the Data Frame Extents from an ArcObjects application

1236
4
06-19-2012 09:09 AM
LarryWilliams
New Contributor III
We're upgrading to ArcGIS 10 and we are changing a number of our feature classes and databases.  To assist our 2500 users we have written a program that converts old layers to the new layers where possible keeping the symbology etc. 

I need a little help in accessing the data frames associated with a map and changing the maximum extent when users click on the zoom out to full extent icon.  Going through the object models can be quite a chore. 

Could someone tell me which objects I'll need to use? 

The program is written in c#.
0 Kudos
4 Replies
LarryWilliams
New Contributor III
Nevermind.  I found it.  Its under the ActiveView

MapDocument aoMapTo = new MapDocument();
string mxdFullToFilePath = this.tbOutputFolder.Text + "\\" + fromFileName;
toFileName = fromFileName;
if (aoMapTo.get_IsPresent(mxdFullToFilePath))
{
     aoMapTo.Open(mxdFullToFilePath);
}
string toDir = this.tbOutputFolder.Text;         
IActiveView aoToActiveView = aoMapTo.ActiveView;
aoToActiveView.FullExtent.Envelope.XMax = 14649;
aoToActiveView.FullExtent.Envelope.YMax = 5678978;
aoToActiveView.FullExtent.Envelope.XMin = -25723;
aoToActiveView.FullExtent.Envelope.YMin = 5631275;
0 Kudos
LarryWilliams
New Contributor III
I guess I still have a problem.  The envelope isn't updateable.  The commands run but it has no effect.
0 Kudos
LarryWilliams
New Contributor III
I finally found this in the ArcObjects SDK 10 Microsoft .NET Framwork

Heres the code in case the link doesn't work.

///<summary>
///Set the extent of the ActiveView to be the maximum extent of a SpatialDomain.
///</summary>
///<param name="spatialReference">An ESRI.ArcGIS.Geometry.ISpatialReference interface that is the input SpatialDomain.</param>
///<param name="activeView">An ESRI.ArcGIS.Carto.IActiveView interface that is the ActiveView for which to recieve the new extent.</param>
///<remarks></remarks>
public void SetMaxExtentOnSpatialDomain(ESRI.ArcGIS.Geometry.ISpatialReference spatialReference, ESRI.ArcGIS.Carto.IActiveView activeView)
{

  System.Double xMin = 0;
  System.Double xMax = 0;
  System.Double yMin = 0;
  System.Double yMax = 0;
  spatialReference.GetDomain(out xMin, out xMax, out yMin, out yMax);

  ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
  envelope.XMax = xMax;
  envelope.XMin = xMin;
  envelope.YMax = yMax;
  envelope.YMin = yMin;

  activeView.Extent = envelope;

}
0 Kudos
DarrylKlassen
New Contributor III
I am trying to read the ActiveView full extent -but am always getting page coordinates as opposed to real world coordinates.  Any thoughts?
0 Kudos