lorieme

error setting parameter as text

Discussion created by lorieme on Sep 1, 2011
Latest reply on May 9, 2017 by s3tech
I've created a simple python script that creates selection criteria based on the current year.  All works fine until I try to pass the parameters as text.

<type 'exceptions.RuntimeError'>: Object: Error in setting parameter as text

For the script parameters in my toolbox, I set up four parameter properties as Type = Derived, Direction = Output, Data Type = String.

What am I doing wrong?


Code:
import arcpy, datetime

currYear = datetime.datetime.today().strftime("%Y")
arcpy.AddMessage("Current Year = " + str(currYear))


# Set Local variables
num3YearsAgo = int(currYear) - 3
num4YearsAgo = int(currYear) - 4
num5YearsAgo = int(currYear) - 5
num6YearsAgo = int(currYear) - 6
num12YearsAgo = int(currYear) - 12

# Set up Selection Criteria to be passed to next step
strCat1 = '"Surf_Hist_Pavement_Year" >= ' + str(num3YearsAgo)
strCat2 = '"Surf_Hist_Pavement_Year" >= ' + str(num5YearsAgo) + ' AND "Surf_Hist_Pavement_Year" <= ' + str(num4YearsAgo)
strCat3 = '"Surf_Hist_Pavement_Year" >= ' + str(num12YearsAgo) + ' AND "Surf_Hist_Pavement_Year" <= ' + str(num6YearsAgo)
strCat4 = '"Surf_Hist_Pavement_Year" < ' + str(num12YearsAgo)


arcpy.AddMessage(strCat1)
arcpy.AddMessage(strCat2)
arcpy.AddMessage(strCat3)
arcpy.AddMessage(strCat4)

# Set Output parameters
arcpy.SetParameterAsText(1, strCat1)
arcpy.SetParameterAsText(2, strCat2)
arcpy.SetParameterAsText(3, strCat3)
arcpy.SetParameterAsText(4, strCat4)

Outcomes