2

I have a tool I am writing that takes in a multiple parameters. The last of these, Codenumber, I want to define to be 1,2,3 or 4. I am attempting to do this by use of a Value List. See below section of my code;

outFC_location = arcpy.GetParameterAsText(0)
end1_Easting = float(arcpy.GetParameterAsText(1))
end1_Northing = float(arcpy.GetParameterAsText(2))    
end2_Easting = float(arcpy.GetParameterAsText(3))
end2_Northing = float(arcpy.GetParameterAsText(4))
fcName = (arcpy.GetParameterAsText(5))
Codenumber = arcpy.Parameter(
    displayName = "Code Number",
    datatype = "float"
    parameterType = "Required"
    direction = "Input"
    multiValue = False)

#Set a list of possible values for runway code.
Codenumber.filter.type = "Valuelist"
Codenumber.filter.list = ["1","2","3","4"]

In the script's properties, under "Parameters", I am unable to set "Value" as described here; https://desktop.arcgis.com/en/desktop/latest/analyze/modelbuilder/value-list-filter.htm

The only fields I can see under "Parameters" are Display Name and Data Type. When running the tool, the input for Codenumber shows no list of inputs.

What is the error in my code or my approach?

2 Answers 2

4

I assume you're running the code directly in ArcMap? In that case this is what you need to do:

  1. Open ArcCatalog and navigate to your toolbox and script
  2. Open properties and navigate to parameters
  3. Add a new parameter with the field type double
  4. Set a value list as filter
  5. Insert the values needed
  6. Edit your code to connect with the value list parameter (i.e. arcpy.GetParameterAsText(<<n>>))
2

This is set in the Tool Validator Class for a regular toolbox and set in the master script if using a python toolbox. In either situation, you make value list filters in the UpdateParameters()` method. Also, if your field is a float value, the value list has to be numeric not text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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