Getting current visible extent

9180
4
10-13-2011 11:35 AM
RobertJones6
New Contributor
Does anyone know how to use Python scripting to get the current visible extent of arcMap? Mostly just need to obtain the min/max X and Y coordinates for the display area. I guess this could also be accomplished by drawing a rectangle to the size of the viewable area and then reading the properties of the rectangle afterward.
Tags (2)
0 Kudos
4 Replies
FrankVignati
Occasional Contributor II
this will give you an extent for a data frame in arcmap

import arcpy
import arcpy.mapping


## Sets the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")
## Sets the Dataframe
DF = arcpy.mapping.ListDataFrames(IMXD, "Layers")[0]

print DF.extent
0 Kudos
RobertJones6
New Contributor
That worked wonderfully. Thank you much!
0 Kudos
JeffBarrette
Esri Regular Contributor
Note - the best, most conistent way to get extent is if you are saving your map document in Layout View.  If your map document is in Data View, your extent may change based on the resizing of application windows.

Same applies to getting and setting scale.

Jeff
0 Kudos
RobertJones6
New Contributor
Note - the best, most conistent way to get extent is if you are saving your map document in Layout View.  If your map document is in Data View, your extent may change based on the resizing of application windows.

Same applies to getting and setting scale.

Jeff


Ah, but what I'm using it for is to get min and max coordinates for the display to dynamically query a MySQL database holding several GB worth of point data. Versus loading the whole thing into arc at once. It's a work around so I don't have to duplicate an already established database. Thanks for the advise though.
0 Kudos