<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to convert Layer off/on python code to a script tool? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-convert-layer-off-on-python-code-to-a/m-p/512800#M40295</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="border: 0px; font-weight: inherit; font-size: inherit; margin: 0px 0px 1em;"&gt;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.&lt;/P&gt;&lt;P style="border: 0px; font-weight: inherit; font-size: inherit; margin: 0px 0px 1em;"&gt;Here is the script I have at the moment.&lt;/P&gt;&lt;P&gt;#Turns all layers off&lt;BR /&gt;p = arcpy.mp.ArcGISProject("Current")&lt;BR /&gt;m = p.listMaps("*")[0]&lt;BR /&gt;lyrList = m.listLayers()&lt;BR /&gt;for lyr in lyrList: &lt;BR /&gt; lyr.visible = False&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#Turns Basemap layer on&lt;BR /&gt;p = arcpy.mp.ArcGISProject("Current")&lt;BR /&gt;m = p.listMaps("*")[0]&lt;BR /&gt;lyrList = m.listLayers('Topographic')&lt;BR /&gt;for lyr in lyrList: &lt;BR /&gt; lyr.visible = True&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: rgba(248, 248, 248, 0.6);"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: rgba(248, 248, 248, 0.6);"&gt;I would really appreciate any help or advice. Thanks.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Nov 2017 17:06:49 GMT</pubDate>
    <dc:creator>Business_IntelligenceSoftware</dc:creator>
    <dc:date>2017-11-20T17:06:49Z</dc:date>
    <item>
      <title>How to convert Layer off/on python code to a script tool?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-convert-layer-off-on-python-code-to-a/m-p/512800#M40295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="border: 0px; font-weight: inherit; font-size: inherit; margin: 0px 0px 1em;"&gt;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.&lt;/P&gt;&lt;P style="border: 0px; font-weight: inherit; font-size: inherit; margin: 0px 0px 1em;"&gt;Here is the script I have at the moment.&lt;/P&gt;&lt;P&gt;#Turns all layers off&lt;BR /&gt;p = arcpy.mp.ArcGISProject("Current")&lt;BR /&gt;m = p.listMaps("*")[0]&lt;BR /&gt;lyrList = m.listLayers()&lt;BR /&gt;for lyr in lyrList: &lt;BR /&gt; lyr.visible = False&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#Turns Basemap layer on&lt;BR /&gt;p = arcpy.mp.ArcGISProject("Current")&lt;BR /&gt;m = p.listMaps("*")[0]&lt;BR /&gt;lyrList = m.listLayers('Topographic')&lt;BR /&gt;for lyr in lyrList: &lt;BR /&gt; lyr.visible = True&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: rgba(248, 248, 248, 0.6);"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: rgba(248, 248, 248, 0.6);"&gt;I would really appreciate any help or advice. Thanks.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2017 17:06:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-convert-layer-off-on-python-code-to-a/m-p/512800#M40295</guid>
      <dc:creator>Business_IntelligenceSoftware</dc:creator>
      <dc:date>2017-11-20T17:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Layer off/on python code to a script tool?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-convert-layer-off-on-python-code-to-a/m-p/512801#M40296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How to create a script tool:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/create-a-python-script-tool.htm" title="http://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/create-a-python-script-tool.htm"&gt;Create a script tool—ArcGIS Pro | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Couldn't find the ArcGIS Pro help page for this, but I assume it's the same in Pro:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/10.3/analyze/modelbuilder/integrating-scripts-within-a-model.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/analyze/modelbuilder/integrating-scripts-within-a-model.htm"&gt;Integrating scripts within a model—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2017 18:20:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-convert-layer-off-on-python-code-to-a/m-p/512801#M40296</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-11-20T18:20:58Z</dc:date>
    </item>
  </channel>
</rss>

