I have a piece of code I'm using to replace layer sources and then zooms to the new features. The part where I replace the workplace source works, but I can't seem to get it to zoom to the extent of the new features. I'm running ArcMap 10.2.
import arcpy
mxd = arcpy.mapping.MapDocument('CURRENT')
mxd.findAndReplaceWorkspacePaths(r"\\Client\L$\17TSLB002_Morice\A95440_1_FULT_21\Submission_GDB\A95440_1_TBA_Digital_Sub_Dec11_2017.gdb",
r"\\Client\L$\17TSLB002_Morice\A95441_1_NO_6\Submission_GDB\A95441_1_TBA_Digital_Sub_Dec1_2017.gdb")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")
lyr = arcpy.mapping.ListLayers(mxd, "BLOCK", df)
df.extent = lyr.getSelectedExtent()
df.scale = 5000
arcpy.RefreshActiveView()
mxd.saveACopy(r"\\Client\L$\17TSLB002_Morice\A95441_1_NO_6\Submission_PDFs\A95441_1_CHR_11by17_Portrait.mxd")
del mxd
I get this error though when I run the script.
Runtime error
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "e:\sw_nt\arcgis\desktop10.2\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "e:\sw_nt\arcgis\desktop10.2\arcpy\arcpy\mapping.py", line 1500, in ListLayers
result = mixins.MapDocumentMixin(map_document_or_layer).listLayers(wildcard, data_frame)
File "e:\sw_nt\arcgis\desktop10.2\arcpy\arcpy\arcobjects\mixins.py", line 820, in listLayers
raise TypeError(str(type(dataframe)))
TypeError: <type 'list'>