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 propertyreferencing this line from the code below: lyr.visible = FalseNote that the mxd and df variables have been defined in code not included.list = ["Layer1", "Layer2", "Layer3", "Layer4", "Layer5", "Layer6"]
for item in list:
[INDENT]for lyr in arcpy.mapping.ListLayers(mxd, "", df):[/INDENT]
[INDENT][INDENT]if item in lyr.name:[/INDENT][/INDENT]
[INDENT][INDENT][INDENT]lyr.visible = True[/INDENT][/INDENT][/INDENT]
[INDENT][INDENT][INDENT]print lyr.name + " turned ON"[/INDENT][/INDENT][/INDENT]
[INDENT][INDENT]else:[/INDENT][/INDENT]
[INDENT][INDENT][INDENT]lyr.visible = False[/INDENT][/INDENT][/INDENT]
[INDENT][INDENT][INDENT]print lyr.name + " turned OFF"[/INDENT][/INDENT][/INDENT]
[INDENT]arcpy.RefreshActiveView[/INDENT]
Any thoughts? Thanks!