LYR_list_MXD = arcpy.mapping.ListLayers(MXD,"*_env*",DF) for LYR in LYR_list_MXD: LYR.visible = False MXD.save() # Turn on each layer individually and export map as new PDF for LYR in LYR_list_MXD: LYR.visible = True output_PDF = OutputPDFFolder + "\\" + str(LYR) + ".pdf" arcpy.mapping.ExportToPDF(MXD, output_PDF) LYR.visible = False MXD.save()
Solved! Go to Solution.
Can you try printing out the lyr name in the list to make sure it is getting populated correctly in your second loop?
Hello Zack,
I have a few quick questions/suggestions.
1) Are all the layers in the same extent? Or should you be zooming to the layers before exporting? (see here)
2) Do you have multiple dataframes? If so, make sure the right one is active. (you can use this: mxd.activeView = df.name)
3) Sometimes an active refresh helps (arcpy.RefreshActiveView())
Good luck!
~Josh
LYR_list_MXD = arcpy.mapping.ListLayers(MXD,"*_env*",DF) for LYR in LYR_list_MXD: LYR.visible = False MXD.save() # Turn on each layer individualy and export map as new PDF for LYR in LYR_list_MXD: print "1." + str(LYR) print "2." + str(LYR.visible) LYR.visible = True print "3." + str(LYR.visible) MXD.save() arcpy.RefreshActiveView() output_PDF = OutputPDFFolder + "\\" + str(LYR) + ".pdf" arcpy.mapping.ExportToPDF(MXD, output_PDF) print "4." + str(LYR.visible) LYR.visible = False print "5." + str(LYR.visible) arcpy.RefreshActiveView() MXD.save()