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.
#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)
Error I receive:
Traceback (most recent call last): File "D:\NET_Projects\HabitatMapGPServices\PrintHabitatMaps\PrintHabitatMaps.py", line 234, in arcpy.SetParameterAsText(7, outputPDF) File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy__init__.py", line 670, in SetParameterAsText return gp.setParameterAsText(index, text) File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\geoprocessing_base.py", line 231, in setParameterAsText self._gp.SetParameterAsText(*gp_fixargs(args, True))) AttributeError: Object: Error in parsing arguments for SetParameterAsText
How my output is set up:
arcpy.SetParameterAsText(7, str(outputPDF))