<?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 Re: Executing Model through ArcPy in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817134#M324</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The syntax I made has disappeared in my first answer, so here it is again:&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;arcpy.env.workspace = r"c:/ArcGISdata"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;arcpy.ImportToolbox(r"c:/ArcGISdata/Workshop.tbx")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;arcpy.Workshopmodel_TestAlias&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;print "Script finished"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;----------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;In which Workshop.tbx is the real name of the toolbox, TestAlias is the alias of the toolbox and Workshopmodel is the name of the model I want to run.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Apr 2016 09:23:39 GMT</pubDate>
    <dc:creator>TinaOosterom1</dc:creator>
    <dc:date>2016-04-14T09:23:39Z</dc:date>
    <item>
      <title>Executing Model through ArcPy</title>
      <link>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817130#M320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt;Recently I found some info about how one can access models in toolboxes using arcpy.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt;The command for accessing the toolbox is &lt;SPAN style="color: black; background: white;"&gt;arcpy.ImportToolbox&lt;/SPAN&gt;&lt;/SPAN&gt;. But it is not clear to me, how to run the model, which command to use.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt;E.G. I have a toolbox called ‘UpdateModels.tbx’. In this toolbox I have created a model called ‘FirstStepUpdate’.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt;The way to access the model would be &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt;ImportToolbox&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt;(&lt;/SPAN&gt;&lt;SPAN class="s"&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: #a31515;"&gt;'c:/ArcGIS/&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt; UpdateModels.tbx&lt;SPAN style="color: #a31515;"&gt;;&lt;/SPAN&gt; FirstStepUpdate&lt;SPAN style="color: #a31515;"&gt;'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-size: 9.0pt; font-family: 'Arial','sans-serif';"&gt;But how do I get arcpy to execute the model?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 06:51:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817130#M320</guid>
      <dc:creator>TinaOosterom1</dc:creator>
      <dc:date>2016-04-14T06:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Model through ArcPy</title>
      <link>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817131#M321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tina,&lt;/P&gt;&lt;P&gt;I'm not an expert but I import the toolbox and then run the model processes separately e.g. if I were to use the Create Routes tool from the Linear Referencing toolbox I would do something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.ImportToolbox("C://path/to/Toolbox.tbx")&lt;/P&gt;&lt;P&gt;arcpy.CreateRoutes_lr(pathtoLayertoCreateRoutesfrom, "ROUTE_ID", pathtoCreatedRoutes, "TWO_FIELDS", "START_", "LENGTH", "UPPER_LEFT", "1", "0", "IGNORE", "INDEX")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might be better exporting your model as python script and take a look at the result in PyScripter or similar&amp;nbsp; - you can learn a lot like that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 07:31:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817131#M321</guid>
      <dc:creator>RebeccaWatson</dc:creator>
      <dc:date>2016-04-14T07:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Model through ArcPy</title>
      <link>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817132#M322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rebecca,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wow, that is quick! Thanks ever so much for responding so promptly.&lt;/P&gt;&lt;P&gt;Your remark about creating Python scripts is correct, but in my case, I have to automate a big bunch of models, that I ‘inherited’ from a colleague that was very productive.&lt;/P&gt;&lt;P&gt;Since he has left already, I struggle most with finding all the input data, for he has been very creative.&lt;/P&gt;&lt;P&gt;So, in order to make some quick progress, it seemed a good idea to, for now, prepare python scripts to execute the models  and schedule those. This would buy me time to fully work them out in ArcPy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, in my script I thought this would be the syntax:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 07:49:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817132#M322</guid>
      <dc:creator>TinaOosterom1</dc:creator>
      <dc:date>2016-04-14T07:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Model through ArcPy</title>
      <link>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817133#M323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tina,&lt;/P&gt;&lt;P&gt;Ok. I'm not sure I fully understand what you need. We run a number of models from python scripts as scheduled tasks each night to update data needed for our web application, but they work like I mentioned above and then the .py file is run via a .cmd file like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start c:\python27\arcgis10.1\python.exe "E:\GIS_Scripts\python\Script.py"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm guessing I don't have experience of what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope you get some answers here.&lt;/P&gt;&lt;P&gt;Rebecca&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 09:06:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817133#M323</guid>
      <dc:creator>RebeccaWatson</dc:creator>
      <dc:date>2016-04-14T09:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Model through ArcPy</title>
      <link>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817134#M324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The syntax I made has disappeared in my first answer, so here it is again:&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;arcpy.env.workspace = r"c:/ArcGISdata"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;arcpy.ImportToolbox(r"c:/ArcGISdata/Workshop.tbx")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;arcpy.Workshopmodel_TestAlias&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #7030a0;"&gt;print "Script finished"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;----------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;In which Workshop.tbx is the real name of the toolbox, TestAlias is the alias of the toolbox and Workshopmodel is the name of the model I want to run.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 09:23:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817134#M324</guid>
      <dc:creator>TinaOosterom1</dc:creator>
      <dc:date>2016-04-14T09:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Model through ArcPy</title>
      <link>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817135#M325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is my code that works. Hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt; import arcpy &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;import sys, os, smtplib, logging, datetime from arcpy &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;import env &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;# Set an gdb admin connection variable. &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;adminConn = "//MACHINENAME/Scripts/ProdDBO_DefaultSDE.sde" &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;# Set a few environment variables &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;arcpy.env.workspace = adminConn &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;arcpy.env.overwriteOutput = True &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;print("Running compress") &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;arcpy.Compress_management(adminConn) &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;# Script arguments Points to the toolbox where the model is located arcpy.ImportToolbox("\\\\MACHINENAME\\Scripts\\FOMScripts.tbx") &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;print "Run UpdateAllSpaces Model" &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;arcpy.UpdateAreaAllSpaces_FOMScripts() &lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2018 23:52:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/executing-model-through-arcpy/m-p/817135#M325</guid>
      <dc:creator>ChadRicks</dc:creator>
      <dc:date>2018-03-15T23:52:05Z</dc:date>
    </item>
  </channel>
</rss>

