I'm working on a script in ArcMap 10.1 that takes a screenshot and I need to know how to extinguish (turn off) a layer in my table of contents.
Answer
The Layer object has a read/write property, visible
, that can be used to turn on/off layers.
This is some basic code that should get you started:
#A list of layer names that you want to be turned off.
names = [x,y,z,etc]
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(, mxd, "Layers")[0]
layers = arcpy.mapping.ListLayers(mxd, "*", df)
for layer in layers:
if layer.name in names:
layer.visible = False
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
No comments:
Post a Comment