How to create a Value Table as an input parameter

1486
0
06-29-2013 04:51 AM
StevePeaslee
Occasional Contributor
I am trying to create an ArcTool using Python in ArcGIS 10.1 SP1. I want to display a two column value table containing string values.

Edit: After rereading the documentation, I discovered that I've been mixing code from standard script tools with that of the new-at-10.1 Python Toolboxes. Value tables aren't a supported parameter dataType for the original script tools, which is rather frustrating.

There will 3 parameters. The first is a text file, second is a temporary string parameter for displaying error messages in my Tool Validation class. The third parameter is my value table.

I found a few bits and pieces of value table code for the tool validation class, but I'm doing something wrong right out of the gate. I keep getting an error message from the getParameterInfo function: AttributeError'>: 'NoneType' object has no attribute 'addRow'. Evidently I'm not defining the table properly and it fails when trying to create the object. I don't actually try add a row to the table, that error gets thrown from the first 'param2' line.

I've tried several variations and set the multValue property to both True and False with no difference. It isn't clear to me whether I need to set the dataType property as composite. Also it is not clear to me whether I need to create this parameter in the Tool Properties interface before hand.

Anybody have a complete working example I could look at? I would greatly appreciate it!

-Steve


  def getParameterInfo(self):
    #Define parameter definitions
    try:
      # Value Table parameter
      param2 = arcpy.Parameter(displayName="Value Table", name="in_featdesc",
                               datatype= "GPValueTable",parameterType="Required",
                               direction="Input",multiValue=True)
      param2.columns = [["FEATSYM","String"],["FEATDESC","String"]]
      #param0.defaultEnvironmentName = "workspace"
      return
    
    except:
      tb = sys.exc_info()[2]
      tbinfo = traceback.format_tb(tb)[0]
      theMsg = tbinfo + "\n" + str(sys.exc_type)+ ": " + str(sys.exc_value)
      self.params[1].value = theMsg
Tags (2)
0 Kudos
0 Replies