3

I am exporting Data Driven Pages using arcpy (ArcMap 10.5, Python 2.7.13). I have used this script many times on this exact same MXD to export DDP to TIFF:

import arcpy

mxd = arcpy.mapping.MapDocument(r"C:\Users\juanzepeda\Desktop\WildCAD GIS\basemap.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):

  mxd.dataDrivenPages.currentPageID = pageNum

  arcpy.mapping.ExportToTIFF(mxd, r"C:\Users\juanzepeda\Desktop\WildCAD 
  GIS\TIF10\basemap10.mxd" + str(pageNum) + ".tif", df, df_export_width=3000, 
  df_export_height=3000, geoTIFF_tags=True)

del mxd

Once in a while, I get the error:

Runtime error 
Traceback (most recent call last):
File "<string>", line 7, in <module>
File "c:\program files 
(x86)\arcgis\desktop10.5\arcpy\arcpy\arcobjects\mixins.py", line 655, in 
dataDrivenPages
return 
convertArcObjectToPythonObject(self._arc_object.pageLayout.dataDrivenPages)
AttributeError: Data Driven Pages is not enabled on this map document.

I created a grid index of my features to use as the data driven layer. Then I make a selection of this layer (to break up large exports into chunks). Sometimes it works, sometimes I get that error. I try restarts, I have reset my %APPDATA% ESRI "user profile", as well as my default template in the %APPDATA% ArcMap 10.5 templates folder.

I try disabling DDP, then re enabling. I have tried Selection>Create layer from selected features, then using that layer for DDP, as well as exporting selected features to new shapefile, and using that for DDP. I don't know why this error occurs and how to fix it.

It happens when DDP is definitely enabled, you can click through them in Data View and it functions as expected. If I click on the attributes of DDP the correct layer and it's attributes show up. But somehow, the system isn't recognizing that DDP are enabled when using the ExportToTIFF.

I found this post on a different DDP export Attribute Error,but it is the only thing I can find evenly vaguely related to my issue. I did try removing the + ".tif" from my export file name like that post suggested but it does not help.

If I remove the layer that DDP is using, I get the warning that I am deleting the index layer being used for DDP. If I don't remove the layer and run my script, I get the error that says DDP are not enabled.

1 Answer 1

1

I fixed the issue by changing the MapDocument file path to "Current", and saving the mxd after each time I changed the layer used by Data Driven Pages.

Basically if any changes were made in the mxd, and not saved, the reference in the script to the MapDocument would be broken.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.