[GIS] Waiting for Python script tool to complete in ModelBuilder

arcgis-desktopmodelbuilderpython-script-tool

I have an Arcgis (10) model which has 2 process that need to be run sequentially.

The 1st process is a python script that creates multiple rasters, but that output is not known to ModelBuilder, therefore I can't use it as a precondition. Or at least not as outline in Example #1 in that page. Maybe there's another route I haven't discovered.

The 2nd process needs those rasters in order to operate. How do I let #2 know when #1 is complete so it may start execution?

To reproduce build a model with:

Process_1: a script which runs PolygonToRaster several times, converting each field in the attribute table to a raster (here, but field list will need to be edited).

Process_2: Run LessThanFrequency Spatial Analyst tool on the results (but really the tool doesn't matter).

Best Answer

As @PolyGeo mentioned, add a fourth parameter to your script tool with the following properties:

  • Data Type: Raster
  • MultiValue: Yes
  • Type: Derived
  • Direction: Output

Then, in your script, build up a list of paths to your output rasters. Upon completion, join them as a semicolon delimited string and pass that to SetParameterAsText to set the derived parameter.

You should then be able to directly connect the script tool to the Polygon to Raster tool.

Related Question