I'm trying to pass a couple of strings from python as parameters in the extract by mask tool in modelbuilder. Unfortunately it doesn't recognize them. When I type them in the parameters it thinks I'm trying to add files called %shp% and %tif% from and to my default gdb. This is my first ever attempt at passing values from python to modelbuilder so I have no idea how to go about trying to fix it. This is also my first question on StackExchange so hopefully everything is clear. Here's the code:
import arcpy import os invalue = arcpy.GetParameterAsText(0) #Getting the basename of the input file newbasename = os.path.basename(invalue).strip("'") newname = os.path.splitext(newbasename) #Creating the strings for the output parameters outshp = newname + ".shp" outtif = newname + ".tif" #Setting the strings as parameters arcpy.SetParameterAsText(1, "C:/Base_Data/Topo/boundary/" + outshp) arcpy.SetParameterAsText(2, "C:/Base_Data/Topo/geotif/" + outtif)
and the model:
As you may have guessed I want to batch process a bunch of these rasters where I have a shapefile of the same name as the mask and want the output to be the same name as the input but in a different location.