Arcpy: Python stops ExportToPDF through list after some iterations

14 views Asked by At

I am having the same issue mentioned here, where it gives the exact same error after the file loops through 3 iterations. there has been no solution to that post and hence asking it again.

I am looping through layers in group layer, and making maps of size 4ft x 6 ft at 200 DPI for each of these layers . It exports the desired maps the first 3 times, but once it starts working on the 4th iteration of the loop, it throws the error below:

Traceback (most recent call last):
  File "d:/work/Non-rotating_Print_Maps_Test.py", line 212, in <module>
    arcpy.mapping.ExportToPDF(mxd, output_pdf, resolution=DPI)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.4\arcpy\arcpy\utils.py", line 182, in fn_
    return fn(*args, **kw)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.4\arcpy\arcpy\mapping.py", line 1156, in ExportToPDF
    layout.exportToPDF(*args)
AttributeError: PageLayoutObject: Error in executing ExportToPDF

I have been manually changing the the MXD file by manually removing the layer for which the map is generated, and re-running the script. It works, but have to keep updating the MXD file after every 3rd iteration. Any clue what is happening and how it can be solved, or how can i restart this python script after every 3rd iteration automatically?

0

There are 0 answers