mxd.dataDrivenPages.pageCount return 0 in Arcpy

74
0
06-17-2020 06:06 AM
PratyakshVijay
New Contributor

I am trying to export data driven pages using Arcpy butmxd.dataDrivenPages.pageCount return 0.

Here what i am doing... first I am replacing the data source of the layer then refreshing the data driven pages and after that using for loop trying to export data driven pages in jpeg.

 

Here what I am trying..

lyr.replaceDataSource(path_of_data_source, "SHAPEFILE_WORKSPACE", "data_source_name")
mxd.dataDrivenPages.refresh()
for
pageNum in range(1,mxd.dataDrivenPages.pageCount + 1😞 arcpy.AddMessage("Image "+ str(pageNum)) mxd.dataDrivenPages.currentPageID = pageNum arcpy.mapping.ExportToJPEG(mxd, directory_env + "\Output_Images/" + str(pageNum) + ".jpeg", resolution = 300)del mxd
0 Kudos
0 Replies