7

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).

1
  • 1
    I think you probably need to use SetParameter or SetParameterAsText at the end of your script to indicate successful completion and then also add it as an output (derived) parameter to the properties of the tool. That should take care of "but that output is not known to Model".
    – PolyGeo
    Commented Jun 2, 2012 at 0:49

1 Answer 1

5

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.

2
  • Thank you. I had a hell of a time getting SetParameter to work properly. I can't put my finger on exactly what makes it so difficult to use, but it is! In the end what made the critical difference is remembering/knowing that the index number used in the script must match the exact order that the parameters are set in the Toolbox item properties, and that the 1st parameter is 0. This would be better if the parameters were names instead of numbers. As it is now it's too easy to change either the script or the toolbox and get them out of sync with each other. Commented Jun 11, 2012 at 17:03
  • 1
    for those that follow: <type 'exceptions.RuntimeError'>: Object: Error in setting parameter as text might mean you're using the wrong index number, e.g. SetParameter(4, something) when you really mean SetParameter(3, something) Commented Jun 11, 2012 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.