Select to view content in your preferred language

df.ZoomToSelectedFeatures not working

3644
2
01-03-2012 01:20 PM
JoshuaChan
Deactivated User
I'd like to take my selected set and zoom to it in the Arcpy.mapping module.

Online I found the df.ZoomToSelectedFeatures but I keep getting this error message:

<type 'exceptions.AttributeError'>: 'DataFrame' object has no attribute 'ZoomToSelectedFeatures'
Failed to execute (testScript)

what does that mean? my code looks like:
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Tantalis Files", df)[0]

lyr_qry = "CROWN_LANDS_FILE = '" + filenum + "'"
print lyr_qry
gp.AddMessage(lyr_qry)
gp.SelectLayerByAttribute_management(lyr , "CLEAR_SELECTION")
gp.AddMessage("old selection cleared")
gp.SelectLayerByAttribute_management(lyr , "NEW_SELECTION", lyr_qry)
df.ZoomToSelectedFeatures(lyr)

gp.RefreshActiveView()
gp.AddMessage("zoomed - happy?")
0 Kudos
2 Replies
JasonScheirer
Esri Alum
df.zoomToSelectedFeatures()
0 Kudos
JoshuaChan
Deactivated User
thanks! I'm never sure what is supposed to go into the brackets.
i've seen examples where stuff is in there and others where it's blank. How do we know when to do what?