How could I adapt the following code to enable me to zoom to each individual selected Geometry one after the other?
import arcpy mxd = arcpy.mapping.MapDocument('CURRENT') df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0] df.zoomToSelectedFeatures() arcpy.RefreshActiveView()
Best Answer
I have a visit tool (in C#, converted from VB.net, which was upgraded from VB6 which was influenced by a tool I wrote in AML)... anyway, the key is to use the Envelope of the geometry in the case of polygon, polyline or multipoint and recentre the map extent.
Here is a very basic start for you:
First you need to check there is a selction against the layer, if there is cursor through the records (remember that if there is a selection against a layer only the selected records are returned) using SHAPE@ to get the geometry object which has an extent as a property, store these in a list and then calling the first one to set the current dataframe extent (also a property).
Note that once the list is made the selection can be changed, this may or may not be what you want. In my case I wanted the extents to remain and be able to edit as I went through the list.