I created a script tool in ArcMap 10.5. How do I set an output parameter from a tool in the script as an input parameter in another tool at a later point in the same script? Like:

buffout = arcpy.GetParameterAsText(5) # Feature class output of buffer analysis-  THIS IS THE VARIABLE I GET AS OUTPUT THAT I WILL LATER USE AS INPUT
buff_dist = arcpy.GetParameterAsText(6) # Buffer distance parameter

# Run the Buffer Analysis tool on stream feature
arcpy.Buffer_analysis(outfc, buffout, buff_dist)

    # Add Parameters 
    outrast = arcpy.GetParameterAsText(7) # Output raster dataset clipped to stream buffer polygons 
    # Run the clip tool on hillshade using "buffout" variable as output extent 
    arcpy.Clip_management(outpath, "", outrast, buffout, "", "ClippingGeometry", 'NO_MAINTAIN_EXTENT') 
   # Add a success message 
   arcpy.AddMessage("Clipping of hillshade to buffer output successful!") 
   # Report any error messages that the Buffer tool might have generated 

I want "buffout", the output from arcpy.Buffer_analysis() step, to be used as an input parameter in arcpy.Clip_analysis().

Do I define buffout as arcpy.SetParameterAsText()?

If so, how and where do I use arcpy.SetParameterAsText() in my script to accomplish my purpose?

I don't understand that function very well.

Also, I'm assuming I must set buffout as a "Derived" parameter type in the script tool properties after using arcpy.SetParameterAsText() correctly?


1 Answer 1


There was no need to set the buffout variable as a derived output using the arcpy.SetParameterAsText(). Defining buffout = arcpy.GetParameterAsText(5) and setting an "Output" direction is sufficient for using an output of a gp tool as an input for another gp tool later on in the script.

Also, I edited the script in my question to show the proper position of parameters in the Clip_management method, which resolved the ExecuteError() I was getting.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.