AnsweredAssumed Answered

How to convert Layer off/on python code to a script tool?

Question asked by bisoftware on Nov 20, 2017
Latest reply on Nov 20, 2017 by dkwiens

I have a python script that turns off all layers in an ArcGIS Pro project and then turns back on the Basemap layer. However, I need to convert this into a script tool so that it can be used in Model Builder. Either as individual script tools, one that turns all layers off and one that turns the Basemap layer back on; or as one script tool that does both.

Here is the script I have at the moment.

#Turns all layers off
p = arcpy.mp.ArcGISProject("Current")
m = p.listMaps("*")[0]
lyrList = m.listLayers()
for lyr in lyrList:
lyr.visible = False


#Turns Basemap layer on
p = arcpy.mp.ArcGISProject("Current")
m = p.listMaps("*")[0]
lyrList = m.listLayers('Topographic')
for lyr in lyrList:
lyr.visible = True

 

 

I would really appreciate any help or advice. Thanks. 

Outcomes