How do you add an output parameter in a python script in a toolbox?
2 Answers
This was a simple question that had found difficult to answer. I searched through the Esri documentation, which is usually very thorough, but just overlooked it. I wanted to share my answer here in a concise manner.
In the Parameters dialog, set up a parameter, and set its direction to "output". Set the type to "Derivative" if applicable.
In the script, use the following command to pass the the feature set/value as output ("1" here is the index for the parameter):
arcpy.SetParameter(1, OutFeatureSet)
(Thanks to Mark's question on the Esri Forums for pointing me to the correct answer! https://geonet.esri.com/thread/57822)
If your input will be the same as your output then you don't need to add a parameter in your code; just create a parameter in your tool and set as you referenced. The obtained from property of the output should be set to your input parameter. This will create an output result to use add an input in model builder. Also, in your code, set your environment for overwrite to true.