1

I am trying to do something very simple, but I'm pulling my hair out with this one.

In an ArcGIS python toolbox, for one of my tools I ask the user for a list of feature layers, using the following code in the .pyt file:

    def getParameterInfo(self):
    """Define parameter definitions"""
    param0 = arcpy.Parameter(
        displayName="Input Line Networks",
        name="InputFCList",
        datatype="GPFeatureLayer", 
        parameterType="Required",
        direction="Input",
        multiValue=True)
    param0.filter.list = ["Polyline"]

The key parameter here is multiValue=True. Then, in my function (where InputFCList is sent), I use this code to pop off the first item in the list of feature classes:

def main(fcList, fcBndPoly, boolSeg, fcOutCombine):
    fcToLine = fcList.pop
    # rest of the code...

This code runs fine during testing, when I hard-coded the list of feature classes. However, when running the tool in ArcMap, I get the following error:

AttributeError: 'unicode' object has not attribute 'pop'

According to the ESRI documentation, setting the multiValue parameter to True should allow for the creation of a list of input feature classes, but there's obviously something else going on if it thinks the list is actually a unicode object. Any ideas?

  • Is it a list? According to the error message it's a string, perhaps it's a semicolon separated string that needs to be split (fcList.split(';')). If it is a list perhaps use for ThisElement in fcList: instead of pop, unless there's a particular reason to get the last item in the list (fcList[len(fcList)-1] should work too.) – Michael Stimson Apr 23 '15 at 0:14
  • Yes, first try print(type(fcList)) and see what you're actually working with. – alphabetasoup Apr 23 '15 at 0:20
2

You haven't shown how you received the parameter value, but I would guess you're likely using parameters[n].valueAsText. Use parameters[n].values instead to receive the value back as a list.

  • 1
    This was exactly the problem. I had all of the parameters being received as .valueAsText. Works great now. Thanks for the quick response! – Jesse Langdon Apr 23 '15 at 0:27

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.