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

181
1
11-20-2017 09:06 AM
Business_IntelligenceSoftware
Occasional Contributor

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. 

0 Kudos
1 Reply
DarrenWiens2
MVP Honored Contributor

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 

0 Kudos