<?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 Loop through and run models in a toolbox in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358741#M69365</link>
    <description>&lt;P&gt;Is it possible to loop through all models in a custom toolbox and run them instead of having to list them individually in the script?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;# Import custom toolbox&lt;BR /&gt;tbx = arcpy.ImportToolbox("E:\HostedFeatureLayers\Stormwater\Stormwater\Default.atbx")&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;tbx.UpdateswInlet()&lt;BR /&gt;print("Finished Append: swInlet")&lt;BR /&gt;tbx.UpdateswManhole()&lt;BR /&gt;print("Finished Append: swManhole")&lt;BR /&gt;tbx.UpdateswDischargePoint()&lt;BR /&gt;print("Finished Append: swDischargePoint")&lt;BR /&gt;tbx.UpdateswWeirStructure()&lt;BR /&gt;print("Finished Append: swWeirStructure")&lt;BR /&gt;tbx.UpdateswOpenDrain()&lt;BR /&gt;print("Finished Append: swOpenDrain")&lt;BR /&gt;tbx.UpdateswPipe()&lt;BR /&gt;print("Finished Append: swPipe")&lt;BR /&gt;tbx.UpdateswDetention()&lt;BR /&gt;print("Finished Append: swDetention")&lt;BR /&gt;except arcpy.ExecuteError:&lt;BR /&gt;print(arcpy.GetMessages(2))&lt;/P&gt;</description>
    <pubDate>Fri, 08 Dec 2023 20:31:56 GMT</pubDate>
    <dc:creator>sk08</dc:creator>
    <dc:date>2023-12-08T20:31:56Z</dc:date>
    <item>
      <title>Loop through and run models in a toolbox</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358741#M69365</link>
      <description>&lt;P&gt;Is it possible to loop through all models in a custom toolbox and run them instead of having to list them individually in the script?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;# Import custom toolbox&lt;BR /&gt;tbx = arcpy.ImportToolbox("E:\HostedFeatureLayers\Stormwater\Stormwater\Default.atbx")&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;tbx.UpdateswInlet()&lt;BR /&gt;print("Finished Append: swInlet")&lt;BR /&gt;tbx.UpdateswManhole()&lt;BR /&gt;print("Finished Append: swManhole")&lt;BR /&gt;tbx.UpdateswDischargePoint()&lt;BR /&gt;print("Finished Append: swDischargePoint")&lt;BR /&gt;tbx.UpdateswWeirStructure()&lt;BR /&gt;print("Finished Append: swWeirStructure")&lt;BR /&gt;tbx.UpdateswOpenDrain()&lt;BR /&gt;print("Finished Append: swOpenDrain")&lt;BR /&gt;tbx.UpdateswPipe()&lt;BR /&gt;print("Finished Append: swPipe")&lt;BR /&gt;tbx.UpdateswDetention()&lt;BR /&gt;print("Finished Append: swDetention")&lt;BR /&gt;except arcpy.ExecuteError:&lt;BR /&gt;print(arcpy.GetMessages(2))&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 20:31:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358741#M69365</guid>
      <dc:creator>sk08</dc:creator>
      <dc:date>2023-12-08T20:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through and run models in a toolbox</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358745#M69366</link>
      <description>&lt;P&gt;for line numbers and proper formatting&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank" rel="noopener"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Now, what happened when you ran it?&lt;/P&gt;&lt;P&gt;You could also have a look at&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/listtools.htm" target="_blank"&gt;ListTools—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;to see if you can run them that way&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 20:42:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358745#M69366</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-12-08T20:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through and run models in a toolbox</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358749#M69367</link>
      <description>&lt;P&gt;The above script worked fine (the formatting didn't come through when I copied it into here).&lt;/P&gt;&lt;P&gt;This is another version I had tried that did not work:&lt;/P&gt;&lt;PRE&gt;import arcpy 
 
tbx = arcpy.AddToolbox("E:\HostedFeatureLayers\Stormwater\Stormwater\Default.atbx")    

tools = arcpy.ListTools("*_Defaultatbx")

for t in tools:  
  try:
    arcpy.t() 
    print(t) 
  except arcpy.ExecuteError:
    print(arcpy.GetMessages(2))&lt;/PRE&gt;&lt;PRE&gt;---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
In  [3]:
Line 9:     arcpy.t() 

AttributeError: module 'arcpy' has no attribute 't'
---------------------------------------------------------------------------&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 20:43:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358749#M69367</guid>
      <dc:creator>sk08</dc:creator>
      <dc:date>2023-12-08T20:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through and run models in a toolbox</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358751#M69368</link>
      <description>&lt;P&gt;Try&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/listtools.htm" target="_blank"&gt;ListTools—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;Something like this, I think&lt;/P&gt;&lt;LI-CODE lang="python"&gt;tbx = arcpy.AddToolbox()
for tool in arcpy.ListTools(tbx):
    tbx.tool()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 20:48:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358751#M69368</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-12-08T20:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through and run models in a toolbox</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358759#M69369</link>
      <description>&lt;P&gt;You just can't 'arcpy.t ' it.&amp;nbsp; Here is a command line example for one of my toolboxes&lt;/P&gt;&lt;LI-CODE lang="python"&gt;tbx = arcpy.AddToolbox(r"C:\arcpro_npg\npGeom_32.atbx")
nme = tbx.__name__
nme
'npgtools'

tools = arcpy.ListTools("*_npgtools")
arcpy.Usage(tools[0])
'AttributeSort_npgtools({Tool}, Input_features, Sort_fields;Sort_fields..., {Output_field})'

arcpy.AttributeSort_npgtools( ..... # now what do you see here for your toolset?&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 08 Dec 2023 21:14:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-and-run-models-in-a-toolbox/m-p/1358759#M69369</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-12-08T21:14:21Z</dc:date>
    </item>
  </channel>
</rss>

