import arcpy Path = os.getcwd() GSP_Join = "C:\\Users\\TDMC0\\AppData\\Local\\Temp\\scratch.gdb\\GSP_Join" mxd = arcpy.mapping.MapDocument(Path + r"\GasLeaks2013.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] Layer = arcpy.mapping.ListLayers(mxd, "", df)[0] Layer2 = arcpy.mapping.ListLayers(mxd, "", df)[1] Layer3 = arcpy.mapping.ListLayers(mxd, "", df)[2] # Create a search cursor try: rows = arcpy.SearchCursor(GSP_Join, "", "", "CONN_OBJ_ID_NUM", "CONN_OBJ_ID_NUM") except Exception as e: print e # Iterate through the Implausible Reads Feature, getting and zooming to respective extents and exporting layout to JPEG. currentState = " " count = arcpy.GetCount_management(GSP_Join) progress = 1 for row in rows: try: if currentState != row.CONN_OBJ_ID_NUM: print "\rExporting Data Driven Pages to JPEG...%s of %s" %(progress, count) currentState = row.CONN_OBJ_ID_NUM where_clause = "\"CONN_OBJ_ID_NUM\"=" + "'" + currentState + "'" arcpy.SelectLayerByAttribute_management(Layer, "NEW_SELECTION", where_clause) df.zoomToSelectedFeatures() df.scale = 5500 arcpy.RefreshActiveView() arcpy.SelectLayerByAttribute_management (Layer, "CLEAR_SELECTION", "") Layer.definitionQuery = where_clause Layer2.definitionQuery = where_clause Layer3.definitionQuery = where_clause arcpy.mapping.ExportToJPEG(mxd, r"E:\GasLeaksProject\2012\JPEG\CONN_OBJ_ID_NUM" + str(currentState) + ".jpeg", resolution=300, jpeg_quality=70) Layer.definitionQuery = "" Layer2.definitionQuery = "" Layer3.definitionQuery = "" progress = progress + 1 except Exception as e: print e
Solved! Go to Solution.
for row in cursor: df.extent = row.Shape.extent