ArcGIS banner

Setting parameters for a script in ArcToolbox

Geoprocessing

Segment 5 of 8

Top  Previous  Next

Right-click your Clip Feature Classes script in the ArcToolbox window and click Open to open its dialog box.

Notice that there are no parameters on the dialog box. This is because they have not been defined for the four system arguments (sys.argv [ ]) you saw in the code. Click Cancel.

Right-click the Clip Feature Classes script and click Properties, then click the Parameters tab.

In the Parameters section, click in the first row under the column heading Display Name. Type “Input Folder” for the name of the parameter.

You must specify the type of data a parameter can store. Click the same row under the column heading Data Type to specify the data type for the parameter. Scroll through the list of data types and click Folder.

Examine the property values set for the Input Folder parameter in the Parameter Properties section of the dialog box. The values that could be set for the property Type are either Required or Optional. As it is required to set an input folder, leave the default value, Required. The values that can be set for the property Direction are either Input or Output. As this parameter is an input parameter—that is, the folder contains the input feature classes that will be clipped—leave the default value, Input.

If the input parameter accepted multiple values, such as multiple folders, you would set the MultiValue property value to Yes. However, here you can only process one folder at a time, so leave the default value, No.

You can specify a default value that will display for the parameter on the tool’s dialog box. For the input folder, you want the default value to be the path to your GP_Tutorial folder.

Type “C:\GP_Tutorial” for the value of the property Default if your GP_Tutorial folder is on your C:\ drive. Alternatively, type the path to your GP_Tutorial folder. This value will be displayed and used by this parameter by default.

Don’t set a value for the Environment property; instead, accept the default. This property will be explained when the XY Tolerance parameter property values are defined.

Attribute domains are used to constrain the values allowed for the parameter. There are two different types of attribute domains: range domains or coded value domains. A range domain specifies a valid range of values, and a coded value domain specifies a valid set of values for a parameter. For this parameter, an attribute domain is not necessary.

Some parameters are dependent on the value of other parameters for information, such as a parameter that lists the fields in an input table. The fields can only be displayed once the input data parameter has a value. The input folder is not dependent on any other parameter, so you’ll use the default.

To set the Input Clip Feature Class parameter, click in the second row under the column heading Display Name. Type “Input Clip Feature Class”. Click the same row under the column heading Data Type to specify the data type for the parameter. Scroll up through the list of data types and click Feature Class. Leave the defaults for the values of the properties Type, Direction, and MultiValue, then type the location for GP_Tutorial\study_quads.shp, such as “C:\GP_Tutorial\study_quads.shp”, for the value of the property Default. This shapefile will be displayed and used as the value for the parameter by default.

To set the Output Workspace parameter, click in the third row under the column heading Display Name. Type “Output Workspace”. Click the same row under the column heading Data Type to specify the data type for the parameter. Scroll through the list of data types and click Workspace. As this parameter is an input parameter (an existing workspace into which the outputs will be placed), accept the default value of input for the property Direction. For the value of the property Default, type the location for GP_Tutorial\Habitat_Analysis.gdb, such as “C:\GP_Tutorial\Habitat_Analysis.gdb”. This personal geodatabase will be displayed and used as the value for the parameter by default. All clipped outputs will, by default, be placed in this location.

To set the XY Tolerance parameter, click in the fourth row under the column heading Display Name. Type “XY Tolerance”. Click the same row under the column heading Data Type to specify the data type for the parameter. Scroll through the list of data types and click Linear unit. Click the row for the property Type in the Value column to open the dropdown list of values. Click Optional. It is not required to specify a value for the XY Tolerance parameter. A default value will be used if there is no value set.

Leave the defaults for the properties Direction, MultiValue, and Default. You could type a value to use as the default. Instead, you’ll take the value set for XY Tolerance from the Environment Settings dialog box to mimic the behavior of the system tools. Click the row for the property Environment in the Value column to open the dropdown list of environment setting values. Click XY Tolerance. The value set for the XY Tolerance in the Environment Settings dialog box will be displayed as the value for the parameter by default. If the value set in the Environment Settings dialog box is changed, the value specified there will be used by the XY Tolerance parameter. Leave the default for the Domain property. If you wanted to limit the range of values that could be set for the parameter, you could set up a domain. The XY Tolerance depends on the input data, so you won’t set a domain for this parameter.

Click OK. The parameters for the script are set.


Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.