Scratchworkspace inline variable usage in Modelbuilder 10.2

816
1
01-31-2014 10:52 AM
TysonSchoepflin
New Contributor II
I was updating a modelbuilder + python script tool for our 10.1 server.  I am using 10.2 desktop.  The model is pushed out as a geoprocessing service.  What was interesting is that the inline variable %scratchworkspace% appeared to be ignored by the "Select" and "Project" tools within the model.  The model creates a sub folder to which shape files are processes and all the files in that sub folder are then zipped.

The Select and Project tools were supposed to place the the files in the sub folder but would just dump things out to the scratch folder.  Here is the line from the select output feature class input field.

%scratchworkspace%\output\ptsTmp.shp

On the desktop the model would run fine.  On the server the shape file would be dumped to the scratch folder, not the output folder.

After a bit of testing it appears that tools that are shared as a geoprocessing service cannot use %scratchworkspace% in their path names.  However, you can create a folder variable and assign it %scratchworkspace%.  Make sure you name the variable something, I used "sws".  I then went through the model and changed the paths to use %sws% instead of %scratchworkspace%, like the following.

%sws%\output\ptsTmp.shp

This worked.  The geoprocessing service on the server placed files in the correct folders after making this change.

Perhaps I missed the documentation somewhere, please point it out if it is there.  It appears that the inline variable %scratchworkspace% does not work in all input fields of modelbuilder tools.  In this case it would be best to create a folder variable, assign it %scratchworkspace%, and then use that variable within the rest of the model.

Just placing this here if anyone else experiences the same problem.
Tags (2)
0 Kudos
1 Reply
TysonSchoepflin
New Contributor II
Don't mean to bump the thread but I can no longer edit the original post.

The new ScratchGDB and ScratchFolder environments
http://blogs.esri.com/esri/arcgis/2012/10/19/the-new-scratchgdb-and-scratchfolder-environments/
0 Kudos