Skip to content

Instantly share code, notes, and snippets.

@OterLabb
Created December 3, 2019 14:39
Show Gist options
  • Save OterLabb/784ce3fe216190980cd945cf1bc9e10e to your computer and use it in GitHub Desktop.
Save OterLabb/784ce3fe216190980cd945cf1bc9e10e to your computer and use it in GitHub Desktop.
Zoom to each feature in a feature class in arcmap
import arcpy
import time
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
lyr = arcpy.mapping.ListLayers(mxd, "Layers", df)[0]
lst_shapes = [row[0] for row in arcpy.da.SearchCursor('feature_class', ['SHAPE@'])]
for shape in lst_shapes:
df.extent = shape.extent
df.scale = 650
arcpy.RefreshActiveView()
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment