I am trying to export multiple maps through one mxd, toggling on/off specific layers for specific maps. My thought is that if I create a list with the string layer names in it, I should be able to cycle through the TOC and turn on those layers, otherwise turn it off. There seems to be a problem once the for loop terminates checking the first list item. Here is the error I am getting:
AttributeError: LayerObject: Error in accessing Visible property
referencing this line from the code below: lyr.visible = False
Note that the mxd and df variables have been defined in code not included.
Any thoughts? Thanks!
list = ["Layer1", "Layer2", "Layer3", "Layer4", "Layer5", "Layer6"]
for item in list:
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
print lyr.name + " turned ON"
print lyr.name + " turned OFF"