AnsweredAssumed Answered

Layer Visible

Question asked by dmarkey on Jul 26, 2017
Latest reply on Jul 27, 2017 by rzufelt

I am attempting to turn a layer on in the Layer of Contents via a python script. When I execute the script below either as a script tool in ArcToolbox or via the python window in ArcMap the visibility status changes in the layer properties but the layer does not turn on in the Table of Contents and the layer does not draw in the data view window. I execute this script within ArcMap and have layers in the Table of Contents which are currently turned off.

 

# Import arcpy module
import arcpy
from arcpy import env
import sys
import os


mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "")[0]
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
    lyr.visible = True
arcpy.RefreshTOC()
arcpy.RefreshActiveView()

Outcomes