6

How do you add an output parameter in a python script in a toolbox?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Oct 3, 2015 at 4:18

2 Answers 2

11

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)

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Oct 3, 2015 at 4:21
1

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.

https://gisnuts.com/terra/blog/2012/09/05/5-tips-for-writing-python-script-tools-applied-to-an-autonumber-tool

answered Oct 4, 2015 at 7:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.