I would like to use a python add-in which uses a button click to iterate through each selected polygon one by one.
The following code manages to zoom only to the first polygon. How can I adapt it to zoom to each selected polygon?
mxd = arcpy.mapping.MapDocument('CURRENT') df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0] Envelopes = [] # store extents here # find the selection set SelLayer = arcpy.mapping.ListLayers(mxd,data_frame=df)[0] # first layer fidSet = arcpy.Describe(SelLayer).FIDSet if len(fidSet) == 0: arcpy.AddMessage("Nothing selected") else: # now cursor through it an get the geometries # storing their extents into a list with arcpy.da.SearchCursor(SelLayer,"SHAPE@") as SCur: for feat in SCur: # I'm going to assume polygon/polyline Envelopes.append(feat[0].extent) # grab the envelope df.extent = Envelopes[0] # first extent arcpy.RefreshActiveView()