1

Can you please let me know how we can set current map to Full Extent enter image description here using ESRI ArcPy?

import arcpy
import arcpy.mapping

# Set the Map to be Full Extent

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.Set-To-Full_Extent

like what the enter image description here is doing on main toolbar

enter image description here

in the ArcMap?

1 Answer 1

4
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "MyDataframeName")[0]
df.zoomToSelectedFeatures()

If you leave the parentheses empty, it zooms to full extent by default.

If you only have a single dataframe you can simplify line 2 to:

df = arcpy.mapping.ListDataFrames(mxd)[0]

Read this help page for further details.

3
  • Thanks Joechoj but I am getting this error Runtime error Traceback (most recent call last): File "<string>", line 5, in <module> IndexError: list index out of range Apr 20, 2017 at 20:15
  • What are the contents of line 5?
    – joechoj
    Apr 20, 2017 at 20:20
  • df = arcpy.mapping.ListDataFrames(mxd, "MyDataframeName")[0] Apr 20, 2017 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.