I know this is an old thread, but a working snip was never posted, so here you go!
TurnOffLayer.py
_________________
import arcpy
fileName=arcpy.GetParameterAsText(0)
mxd = arcpy.mapping.MapDocument("CURRENT")lyr=arcpy.mapping.ListLayers(mxd, fileName)
if lyr: if lyr[0].visible==True: lyr[0].visible=False arcpy.RefreshActiveView()
sys.argv[2]=Truearcpy.SetParameter(1,"True")
layerlist = arcpy.mapping.ListLayers(...) if layerlist: do_something() else: handle_empty_layer_list()
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.