Using a Python Script Tool in Modelbuilder

1065
6
03-06-2020 07:44 AM
JohnBrand
New Contributor III

I'm running ArcPro 2.2.

I wrote a small Python script and saved it as a Python Script Tool in my Toolbox.  It has no parameters.

I want to use it in in Model Builder in one of my existing models and I'm having trouble.  All I want to do is make sure that the script runs first before the rest of the model.  How do I make my script a precondition for the rest of the model?

Thanks

0 Kudos
6 Replies
DanPatterson_Retired
MVP Esteemed Contributor
0 Kudos
JohnBrand
New Contributor III

I want to make it a precondition.  Not sure how.  It won't allow me to connect it to anything else in the model.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

sounds like you can make one of your inputs the precondition

0 Kudos
JohnBrand
New Contributor III

I don't follow.

My script (circled in green) downloads a zip file, unzips it, and overwrites existing data on my network.  How do I make the newly downloaded data a precondition to execute the model?

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Make the folder where your zip is located a parameter, even if you provide defaults, since I can only assume that your next two inputs come from there.  that won't necessarily work since the zip may take more time that you need to use it as an input to something else.  You could alternately add another boolean parameter to your script... "continue" and check for its value after the download and unzip in your script.  You could even add a time.sleep to delay completion of the script to allow for unzip

0 Kudos
JohnBrand
New Contributor III

Like this?

Setting the Default to the folder where the data is saved & extracted?

0 Kudos