Looping through features

Discussion created by johannessbg on Mar 29, 2012
Latest reply on Apr 2, 2012 by mzcoyle

I'm quiet new in python and i have the following question.

I want to export my map into jpg's with worldfile. Therfore i created a polygon-featureclass with a grid (400 objects).
As it is a little uninteresting to select and pan to every single polygon and export it, i tried to write a script doing that for me.
The problem is that i do not know how to loop through the features.

This is the code a made.

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
gridLayer = arcpy.mapping.ListLayers(mxd, "Grid", df)[0]
arcpy.SelectLayerByAttribute_management(gridLayer, "NEW_SELECTION", "SORT_ID = 1")
df.extent = gridLayer.getSelectedExtent(False)
df.scale = 100000
arcpy.mapping.ExportToJPEG(mxd, r"C:\Daten\Images\Image1.jpg", df, df_export_width=1600, df_export_height=1200, world_file=TRUE)
del mxd

Thank you in advance,