AnsweredAssumed Answered

Python Toolbox, selected value from dropdown box "disappears" after selection

Question asked by JCanno on Sep 17, 2020
Latest reply on Sep 22, 2020 by JCanno

I have not found anything on this issue, and it is not easy to search for. I have a Python Toolbox that has multiple, user-selected feature class inputs with each feature class input having 3 or 6 dropdowns for values. The tool is set up so the feature class inputs are optional and each value input is optional, basically, the user can choose to include a feature class and include 1 to 6 values from that feature class. This setup was as per the requester, so I am trying to maintain it as close as possible.  As the title says, I am having values "disappear" after selecting the value; I click on the value, it shows in the box, and then resets to zero or none, depending on the box. This is behavior is occurring on features with 6 values; with values 1 and 2 working properly and 3-6 showing then disappearing after selection. I am not seeing this behavior on 3 value features, all three dropdowns work as expected. I have the dropdown values hardcoded in the toolbox and have copied a portion of the script into a new toolbox and tested auto-populating dropdown values from within def updateParameters(self, parameters). Dropdowns populate correctly but exhibit the same behavior as the hardcoded ones. I have attached two short screen captures. Geocapture is from the complete toolbox showing a three value feature with no issues, and a 6 value feature with "disappearing" selections. Geocapture2 is from the test-toolbox and auto-populates the values based on the feature and exhibits the same behavior. Please note, the screen capture videos did not capture the dropdown boxes popping up. The block of code starting with "params13" is from the complete toolbox. I did not post the entire script as it is around a thousand lines long. The second block of code is from the test-toolbox using auto-populate. I think this is a recent occurrence, possibly after 2.6 came, out because this was written and tested back in May and June and was working and has cropped up in the final testing and editing. Any ideas on where to go from here or possible fixes would be most appreciated. I am guessing it is something simple and I am just missing it.

params13 = arcpy.Parameter(
            displayName="Vegetation Feature Class",
            name="inVegfeature",
            datatype="DEFeatureClass",
            parameterType="Optional",
            direction="Input",)
        params13.value = None

        # First Input
        params14 = arcpy.Parameter(
            displayName="First Vegeation Class",
            name="veg1",
            datatype="GPDouble",
            parameterType="Optional",
            direction="Input")
        params14.value = 0
        params14.filter.list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                                26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
                                38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
                                50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
                                62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
                                74, 75, 76]
        # Second Input
        params15 = arcpy.Parameter(
            displayName="Second Vegetation Class",
            name="veg2",
            datatype="GPDouble",
            parameterType="Optional",
            direction="Input",)
        params15.value = 0
        params15.filter.list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                                26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
                                38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
                                50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
                                62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
                                74, 75, 76]
        # Third Input
        params16 = arcpy.Parameter(
            displayName="Third Vegeation Class",
            name="veg3",
            datatype="GPDouble",
            parameterType="Optional",
            direction="Input",)
        params16.value = 0
        params16.filter.list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                                26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
                                38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
                                50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
                                62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
                                74, 75, 76]
        # Fourth Input
        params17 = arcpy.Parameter(
            displayName="Fourth Vegeation Class",
            name="veg3",
            datatype="GPDouble",
            parameterType="Optional",
            direction="Input",)
        params17.value = 0
        params17.filter.list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                                26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
                                38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
                                50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
                                62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
                                74, 75, 76]
        # Fifth Input
        params18 = arcpy.Parameter(
            displayName="Fifth Vegeation Class",
            name="veg3",
            datatype="GPDouble",
            parameterType="Optional",
            direction="Input",)
        params18.value = 0
        params18.filter.list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                                26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
                                38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
                                50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
                                62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
                                74, 75, 76]
        # Sixth Input
        params19 = arcpy.Parameter(
            displayName="Sixth Vegeation Class",
            name="veg3",
            datatype="GPDouble",
            parameterType="Optional",
            direction="Input",)
        params19.value = 0
        params19.filter.list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                                26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
                                38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
                                50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
                                62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
                                74, 75, 76]                                                                       
# -*- coding: utf-8 -*-

import arcpy


class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""

        self.label = "Toolbox"
        self.alias = ""

        # List of tool classes associated with this toolbox
        self.tools = [Tool]


class Tool(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "Tool"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""
        # Geology Class Feature Class Parameters
        params0 = arcpy.Parameter(
            displayName="Geology Feature Class",
            name="inGeofeature",
            datatype="DEFeatureClass",
            parameterType="Optional",
            direction="Input",)
        params0.value = None
        # First Input
        params1 = arcpy.Parameter(
            displayName="First Geology Class",
            name="geo1",
            datatype="GPString",
            parameterType="Optional",
            direction="Input")
        params1.value = None
       
        # Second Input
        params2 = arcpy.Parameter(
            displayName="Second Geology Class",
            name="geo2",
            datatype="GPString",
            parameterType="Optional",
            direction="Input",)
        params2.value = None

        # Third Input
        params3 = arcpy.Parameter(
            displayName="Third Geology Class",
            name="geo3",
            datatype="GPString",
            parameterType="Optional",
            direction="Input",)
        params3.value = None
       
        # Fourth Input
        params4 = arcpy.Parameter(
            displayName="Fourth Geology Class",
            name="geo3",
            datatype="GPString",
            parameterType="Optional",
            direction="Input",)
        params4.value = None

        # Fifth Input
        params5 = arcpy.Parameter(
            displayName="Fifth Geology Class",
            name="geo3",
            datatype="GPString",
            parameterType="Optional",
            direction="Input",)
        params5.value = None
       
        # Sixth Input
        params6 = arcpy.Parameter(
            displayName="Sixth Geology Class",
            name="geo3",
            datatype="GPString",
            parameterType="Optional",
            direction="Input",)
        params6.value = None
       
        params = [params0, params1, params2, params3, params4, params5, params6]
        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""

        if parameters[0].value:
            with arcpy.da.SearchCursor(parameters[0].valueAsText, "GLG_SYM") as rows:
                parameters[1].filter.list = sorted(list(set([row[0] for row in rows])))
        if parameters[0].value:
            with arcpy.da.SearchCursor(parameters[0].valueAsText, "GLG_SYM") as rows:
                parameters[2].filter.list = sorted(list(set([row[0] for row in rows])))
        if parameters[0].value:
            with arcpy.da.SearchCursor(parameters[0].valueAsText, "GLG_SYM") as rows:
                parameters[3].filter.list = sorted(list(set([row[0] for row in rows])))
        if parameters[0].value:
            with arcpy.da.SearchCursor(parameters[0].valueAsText, "GLG_SYM") as rows:
                parameters[4].filter.list = sorted(list(set([row[0] for row in rows])))
        if parameters[0].value:
            with arcpy.da.SearchCursor(parameters[0].valueAsText, "GLG_SYM") as rows:
                parameters[5].filter.list = sorted(list(set([row[0] for row in rows])))
        if parameters[0].value:
            with arcpy.da.SearchCursor(parameters[0].valueAsText, "GLG_SYM") as rows:
                parameters[6].filter.list = sorted(list(set([row[0] for row in rows])))
       
        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""

        return

    def execute(self, parameters, messages):
        """The source code of the tool."""
        return

Attachments

Outcomes