Arcpy ZoomToFeatures Not working Exactly !

716
1
07-12-2011 11:16 AM
PawanVuppala
Occasional Contributor
Hello,
I have an arcpy script that I run which generates PDF Maps every week and sometimes it zooms to a layer that I'm interested by doing a select and zoomtofeatures but doesnt always work.  Its very inconsistent and I'm not sure why..
These are the few lines that I have which selects/zooms to the area of interest.
 
lyr.definitionQuery = whereOrders
            arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", whereOrders)
            df.zoomToSelectedFeatures()
            df.Extent = lyr.getSelectedExtent()


Attaching the sample output for reference.

Appreciate any feedback on this...

Thanks!

-Pawan Vuppala
0 Kudos
1 Reply
JeffBarrette
Esri Regular Contributor
Your code is doing 2 different forms of zoom.

df.zoomToSelectedFeatures zooms to selected features in ALL layers.

df.extent = lyr.getSelectedExtent() zooms to features ONLY in that layer.

It would make sense that you get different results if you sometimes have other selected features.

Jeff
0 Kudos