AnsweredAssumed Answered

arcpy visible not working

Question asked by zackb11 on Feb 4, 2014
Latest reply on Feb 4, 2014 by posthumusb
I have  a script that adds .lyr files to an MXD.

A loop then iterates through the layers in the MXD and turns them all OFF, using the lyr.visible = False function. This part of my code works.

I then want to iterate through the list again, turn on the first layer, export the map as a PDF, turn off the layer, then move onto the next layer. This is the part that doesn't work. The layers do not turn on again. The PDFs export, but they are all blank.

I've seen this question asked before, but the solutions listed don't seem to be working for me.

I've posted the code below.

LYR_list_MXD = arcpy.mapping.ListLayers(MXD,"*_env*",DF)  for LYR in LYR_list_MXD:         LYR.visible = False  # 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

Any suggestions would be greatly appreciated.