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?

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.

  • 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 – user1106951 Apr 20 '17 at 20:15
  • What are the contents of line 5? – joechoj Apr 20 '17 at 20:20
  • df = arcpy.mapping.ListDataFrames(mxd, "MyDataframeName")[0] – user1106951 Apr 20 '17 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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