Select to view content in your preferred language

arcpy.SetParameter - Multiple output parameters

3901
1
06-23-2014 12:52 PM
BakaryKoné
Deactivated User
Hi guys,

Is it possible to set more than one output parameter using arcpy.setparameter  ?




index = arcpy.GetArgumentCount()-1
output1 = "out1"
arcpy.SetParameter(index , output1)
output2 = "out2"
arcpy.SetParameter(index+1, output2)
Tags (2)
0 Kudos
1 Reply
OwenEarley
Frequent Contributor
You can have multiple output parameters. For example, the following takes 2 input parameters then creates 4 output values:

import arcpy

n1 = float(arcpy.GetParameterAsText(0))
n2 = float(arcpy.GetParameterAsText(1))

out1 = n1 + n2
arcpy.SetParameter(2, out1)
out2 = n1 - n2
arcpy.SetParameter(3, out2)
out3 = n1 * n2
arcpy.SetParameter(4, out3)
out4 = n1 / n2
arcpy.SetParameter(5, out4)


Results:
[ATTACH=CONFIG]34829[/ATTACH]

Just make sure to set the Direction to Output in the Parameter properties when creating the script tool:
[ATTACH=CONFIG]34830[/ATTACH]
0 Kudos