AnsweredAssumed Answered

Using Output Parameters in Input Parameters in Script Tools

Question asked by jbrengel on Mar 17, 2018
Latest reply on Mar 26, 2018 by curtvprice

Hi,

 

I created a script tool in ArcGIS using Python.   While the script tool is mostly functional, it does not complete the final step.  This step is as follows in the Python code (Note: the syntax highlighter doesn't seem to work correctly but I think the syntax is right):

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

I have already defined buffout as arcpy.GetParameterAsText(5) and used it as an ouput parameter in arcpy.Buffer_analysis in a previous step in my code not shown above.  In my script tool Properties, under the "Parameters" tab, I have set up buffout as a "Required" parameter with a direction of "Output".    I'm assuming my problem is that I can't use an output parameter as an input parameter in a later step of code without adjusting the code somehow. 

 

How do I write code to use this output parameter as an input parameter in the arcpy.Clip_management() portion of my code above?  I've struggled with this concept while designing script tools and it would be helpful to have a clear, exact method.  If this is not the problem and my assumption is wrong, I'd appreciate any thoughts on another solution.  Thanks!

Outcomes