I have a project where we create multiple mxd's per geographic area. Each mxd contains a unique definition query for 3 layers. I then select the 3 layers in the Table of Contents view and right-click for "Zoom to Layers". None of the 3 layers are consistently the largest, so I need to approximate this behavior using Arcpy.
Is there a way to do so?
Here are the steps I have taken so far:
- Group the layers, then zoom to layer on the group. I have been getting strange behavior from this and the zoom goes out much further than the actual extent when I zoom to the layers individually selected.
- Try to use ListLayers to select multiple layers, but I cannot determine if this is possible.
- Use the following code to zoom to the extents:
... lyr = arcpy.mapping.ListLayers(mxd, "", df)[LayerNum]
... ext = lyr.getExtent()
... df.extent = ext
I get inconsistent zooms from this, where it will zoom out VERY far (58 mil), and then zoom in incrementally (35 mill, 6 mill, etc) as I apply the function again until it finally zooms to the actual layer extent.
My next solution will be to try selecting the individual features of each layer and using "Zoom to selected features".