ModelBuilder: Open shapefile using parsed filename

4393
10
Jump to solution
07-22-2015 12:44 PM
GaryHoffmann
New Contributor II

I'm trying to build a model that will iterate through a series of xyz text files, and clip each text file using a similarly named shapefile on a one-to-one basis. So example01.txt has a corresponding polygon shapefile, example01.shp, which will be used to clip it. So I've parsed out the filename, example01, but when I try to use that as the Clip Feature in the Clip tool, the model refuses to start, claiming that %filename%.shp does not exist. What am I missing? Is there a way to do this?

I've already tested a simpler model that will convert the text files to multipoint shapefiles, and that works on its own. But I can't get Arc to recognize that it needs to evaluate the filename variable prior to checking for the existence of the shapefile.

Thanks.

Model.png

Error.png

0 Kudos
10 Replies
GaryHoffmann
New Contributor II

I contacted ESRI Tech Support and they confirmed that variables can't be used as inputs to a process. So you have to use Calculate Value with some python code to generate an intermediary output, which gives you more freedom to parse out particular substrings from a filename, anyway. Working version shown below. Thanks, everyone, for your help.

CalculateValue.png

WorkingArcModel.png