Select to view content in your preferred language

How to get fields from GPValueTable feature classes in UpdateParamters function, arcpy.Describe throws error while we input model builder variable(which is out put from other tool)

561
0
07-25-2019 11:58 AM
SivaSontineni
New Contributor

Below is the sample code which throws error when used in model builder and set input from other tool

class CombinedTool(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "CombinedLRTool"
        self.description = "CombinedTool"
        self.canRunInBackground = False
        self.params = arcpy.GetParameterInfo()
    def getParameterInfo(self):
        """Define parameter definitions"""

        in_tables = arcpy.Parameter(
            displayName="Input Layers",
            name="InputLayers",
            datatype="GPFeatureLayer",
            parameterType="Required",
            direction="Input")

        in_seg = arcpy.Parameter(
            displayName="Seg Layers",
            name="in_seg",
            datatype="GPValueTable",
            # parameterType="Optional",
            direction="Input")
        in_seg.columns = [["GPTableView", "layer"]]

        testvalue = arcpy.Parameter(
            displayName="Test Field",
            name="testvalue",
            datatype="GPString",
            direction="Input")

        params = [in_tables,in_seg,testvalue]
        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."""        
        lyrdscr = arcpy.Describe(parameters[1].value[0][0])
        parameters[2].value = str([f.name for f in lyrdscr.fields])        

        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):


        return
Tags (1)
0 Kudos
0 Replies