AnsweredAssumed Answered

Zoom To Each Record Search Cursor

Question asked by EscondidoAnalyst on Nov 8, 2017
Latest reply on Nov 9, 2017 by Dan_Patterson

I know I almost have this right but it selects all records and doesn't zoom to each record - one by one

 

import arcpy
mxd = arcpy.mapping.MapDocument ('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]

# y = input("Type Layer Nmae :")
fc = r'Orders_High_RD'
lyr = arcpy.mapping.ListLayers(mxd, fc, df)[0]
#df.extent = lyr.getSelectedExtent()
df.scale = 1000 # we set the scale to 1000
#arcpy.RefreshActiveView()


with arcpy.da.SearchCursor(fc, "OBJECTID") as cursor:
    row = cursor.next()
    for row in cursor:
        df.extent = lyr.getSelectedExtent()
        arcpy.SelectLayerByAttribute_management(fc,"NEW_SELECTION")
        #df.zoomToSelectedFeatures()
        arcpy.RefreshTOC()
        arcpy.RefreshActiveView()

Outcomes