AnsweredAssumed Answered

Problems parsing SetParameterAsText

Question asked by MollyKFoley on Nov 1, 2018
Latest reply on Nov 2, 2018 by MollyKFoley

I think I have all my indexing correct.


I have 8 parameters in my script tool. 7 input and 1 derived output. Indexing for GetParameterAsText starts at 0, so logically my SetParameterAsText should have an index of 7, considering my output parameter is the last one in the list.

I use sys.argv to set my input parameters in the script. This index starts at 1.


My script:

#Get all the inputs from the user
year = sys.argv[1] #GetParameterAsText(0)
state = sys.argv[2] #GetParameterAsText(1)
cipArea = sys.argv[3] #GetParameterAsText(2)
layerString = sys.argv[4] #GetParameterAsText(3)
renderer = sys.argv[5] #GetParameterAsText(4)
orientation = sys.argv[6] #GetParameterAsText(5)
emailAddr = sys.argv[7] #GetParametersAsText(6)

#Do a ton of stuff

outputPath = os.path.join(arcpy.env.scratchFolder, "Map.pdf")
outputPDF = arcpy.mapping.ExportToPDF(mxd, outputPath)
arcpy.SetParameterAsText(7, outputPDF)


How the output parameter is set (there are 8 parameters, I just can't expand the window to show them all):


Input window (don't mind the x's):


Anybody know what could be happening? This is the error I get back:

Traceback (most recent call last):
File "D:\NET_Projects\HabitatMapGPServices\PrintHabitatMaps\", line 234, in <module>
arcpy.SetParameterAsText(7, outputPDF)
File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\", line 670, in SetParameterAsText
return gp.setParameterAsText(index, text)
File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\geoprocessing\", line 231, in setParameterAsText
self._gp.SetParameterAsText(*gp_fixargs(args, True)))
AttributeError: Object: Error in parsing arguments for SetParameterAsText