Select to view content in your preferred language

Filter Lists on Parameters Python Toolbox

6494
2
Jump to solution
12-28-2015 03:02 PM
MatthewRusso
Emerging Contributor

For some reason I am running into an issue on a filter list for my tool box.

Below is my Code:

def getParameterInfo(self):
   """Define parameter definitions"""
   prod = "\\hqstore\geostore\Software\Scripts\Python_Toolbox\ConnectionFiles\PRODUCTION_10.2.2_GISUser_Default.sde"
   test = "\\hqstore\geostore\Software\Scripts\Python_Toolbox\ConnectionFiles\Test_10.2.2_GISUser_Default.sde"
   dev = "\\hqstore\geostore\Software\Scripts\Python_Toolbox\ConnectionFiles\Dev_10.2.2_GISUser_Default.sde"

   from_database = arcpy.Parameter(
   displayName = "From Database",
   name = "From_Database",
   datatype = "DEWorkspace",
   parameterType = "Required",
   direction = "Input")

   #from_database.filter.type = "ValueList"
  #from_database.filter.list = [prod, test]

   to_database = arcpy.Parameter(
   displayName = "To Database",
   name = "To_Database",
   datatype = "DEWorkspace",
   parameterType = "Required",
   direction = "Input")

   #to_database.filter.type = "ValueList"
  #to_database.filter.list = [test, dev]

   parameters = [from_database, to_database]
   return parameters

any ideas why this is not working? the filters are commented out... so my tool works

# Ignore my spacing it is just how the copy paste ended up

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
FreddieGibson
Honored Contributor

The error you're seeing is expected. When using a parameter of type workspace the only filter values that you can use are to filter the type of workspace supplied (i.e. File System, Local Database, or Remote Database).

You'll want to use a parameter type that allows you to have a dropdown with known paths, such as GPString.

This is documented on the following page and holds true for both script tools and python toolboxes.

Defining parameters in a Python toolbox

http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/defining-parameters-in-a-python-t...

parameter.png

Setting script tool parameters (Script tool equivalent to the above documentation)

http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/setting-script-tool-parameters.ht...

** Screenshot of filters that become available in the UI against a parameter of type DEWorkspace. **

filter.png

View solution in original post

2 Replies
FreddieGibson
Honored Contributor

The error you're seeing is expected. When using a parameter of type workspace the only filter values that you can use are to filter the type of workspace supplied (i.e. File System, Local Database, or Remote Database).

You'll want to use a parameter type that allows you to have a dropdown with known paths, such as GPString.

This is documented on the following page and holds true for both script tools and python toolboxes.

Defining parameters in a Python toolbox

http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/defining-parameters-in-a-python-t...

parameter.png

Setting script tool parameters (Script tool equivalent to the above documentation)

http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/setting-script-tool-parameters.ht...

** Screenshot of filters that become available in the UI against a parameter of type DEWorkspace. **

filter.png

MatthewRusso
Emerging Contributor

Thanks for the Info!!! That worked.

0 Kudos