import arcpy from arcpy import mapping mxd = mapping.MapDocument("CURRENT") df = mapping.ListDataFrames(mxd)[0] lyr = mapping.Layer(arcpy.GetParameterAsText(0)) df.extent = lyr.getSelectedExtent() del mxd
import arcpy # put map info into variable mxd mxd = arcpy.mapping.MapDocument("CURRENT") arcpy.AddMessage ("0") # get layer from user lyr = arcpy.GetParameterAsText (1) arcpy.AddMessage ("1") # get list of data frames df = arcpy.mapping.ListDataFrames(mxd)[0] arcpy.AddMessage ("2") #zoom to the selected layer df.extent = lyr.getSelectedExtent() arcpy.AddMessage ("3")
mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] df.zoomToSelectedFeatures()
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.