jhchan69

df.ZoomToSelectedFeatures not working

Discussion created by jhchan69 on Jan 3, 2012
Latest reply on Jan 5, 2012 by jhchan69
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?")

Outcomes