worspace as parameter in Model Builder

Discussion created by wgivens on Aug 5, 2011
Latest reply on Aug 5, 2011 by bruce.nielsen
I've got a question that is probably stupid easy to answer (I hope).  I wrote a simple Python script to batch clip rasters to a single shapefile.  I want to import this as a script in a toolbox.  That part works fine.  I want to expose the input and output directories as well as the clip_shape as parameters in the tool box.  I went into the properties of the script (after inport) and added those to parameters.  What do I need to add to my code to accept the parameter input assuming the first parameter asks for input directory, the second parameter asks for output directory, and the third asks for the feature class to clip by?

# Python script for batch clipping rasters

import arcgisscripting

gp = arcgisscripting.create()

gp.workspace = "C:/Temp"
rasList = gp.ListRasters()
count = 0
name = rasList.next()
while name != None:
 clipshape = "C:/Temp/clip_shape.shp"
 outworkspace = "C:/Temp/clipped/"
 outname = name.split(".")[0] + str(count) + "_clip.tif"
 gp.compression= "LZW"
 gp.Clip_management(name, "#", outworkspace + outname, clip_shape, "#", "ClippingGeometry")
 count = count + 1
 name = rasList.next()