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.
How to create a script tool:
Create a script tool—ArcGIS Pro | ArcGIS Desktop
Couldn't find the ArcGIS Pro help page for this, but I assume it's the same in Pro:
Integrating scripts within a model—Help | ArcGIS for Desktop