Python Script in Model Builder

2717
1
06-04-2014 09:48 AM
DaveCouture
New Contributor III
I have a model builder that creates a MobileCache (using the Mobile Tool) and a python script that empties the MobileCache folder.  I want the script to run first, then the Mobile Tool, but I can't seem to find a way. Using a precondition does not work.  I'm using ArcGIS 10.0.
Tags (2)
0 Kudos
1 Reply
ScottMoyer
Occasional Contributor

Dave,

I think I found an answer for you (sorry for the late reply). I had the same issue and found a 2004 entry by Ghislain Prince in the ARCHIVE FORUMS. Here's the thread: Run EXE at the start of a Model‌. I was able to create a preconditon derived from a first-to-run Python script in the model, and I successfully ran a portion of my model.

Scott

PS Link isn't working. Here's the entry:

SubjectRe: Run EXE at the start of a Model
AuthorGhislain Prince
DateMay 31, 2004
MessageHi Kevin,
preconditions are based on variables (circles
in model builder). Currently your tool (EXE) has no parameters or variables.
What you want to do is add a parameter to it. To do so:

1) Right click
your exe in ArcToolbox
2) select PROPERTIES
3) click in the grid and add
a parameter with the following properties
- Name: type whatever you want
here
- Data Type: Boolean
- type: Derived
- Direction: Output
-
Default: TRUE
- leave the remaining properties to their defaults

Now
drop this tool into your model again, you'll notice that the tool now has a
variable (cicle) to it's right (output). So now you can specify this variable as
a PRECONDITION to other processes.

So what actually happens when the
model runs: once you've added a precondition on the output of your script the
next process will not run until your script (EXE) has been run. Once your script
has been run, the next process will check the variable and see that it is TRUE
(since that's the default), so then the next process will run.

Ghislain
Prince
Ghislain Prince
ESRI
0 Kudos