HOW TO

Control the default values for a multivalue input parameter within a Python script-based tool

Last Published: April 25, 2020

Summary

Instructions provided on how to use the ToolValidator class to populate default values into the tool dialog for a script-based tool.

Procedure

Using the initializeParameters and updateParameters methods, the default values for a mutivalue parameter can be created and controlled.

  1. To add custom behavior for your script tool, right-click the script tool, click Properties, then click the Validation tab. On the Validation panel, you can provide Python code that implements a Python class named ToolValidator.

    [O-Image]
  2. In the Python editor, edit the initializeParameters method code block to create a filter list of acceptable values for the corresponding parameter:

    [O-Image]
  3. To make some or all of the filter list values selected by default, pass in a string, separated by semicolons into the parameter:

    [O-Image]
  4. The result of the edited ToolValidator class is a parameter that is updated and set upon opening of the script tool dialog:

    [O-Image]

Article ID:000011291

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