HOW TO

Add an output parameter in the script tool for ModelBuilder

Last Published: July 10, 2020

Summary

To use a script tool in ModelBuilder, the input and output parameters must be set. If there are no output parameters set in the script tool, the output result cannot be used in a different tool within ModelBuilder. This can be tricky, because the output location can be specified within a script, but the output result cannot be used. If the script tool without any output parameter is inserted in a model, the tool displays without any input or output available as shown in the image below.

User-added image

This article provides steps to add an output parameter in a script tool for ModelBuilder.

Procedure

  1. Create a script tool of a desired tool with the GetParameter() method for the input and output parameter. Refer to ArcMap: Adding a script tool for more information. The following script uses the Feature Class To Feature Class tool as an example.
import arcpy

# Set local variables
inFeatures = arcpy.GetParameter(0)
outLocation = "C:/output.gdb"
outFeatureClass = arcpy.GetParameter(1)

# Execute the tool
arcpy.FeatureClassToFeatureClass_conversion(inFeature, outLocation, outFeatureClass)
  1. Add the parameters to the script tool. Right-click the script tool in the Catalog pane and click Properties.
  2. Click the Parameters tab.
  3. Add Input and Output under Display Name and specify the Data Type according to the tool used. In the following example, the Data Type is set to Feature Class.
  4. In the same window, under Parameter Properties section, specify the Direction properties value as Output.
The image of the Script Properties window.
  1. Add the tool to the model. The tool is inserted alongside an Output parameter.
The image of the Script tool in a Model

Article ID:000013730

Software:
  • ArcMap

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic