2

I have a set of models that use Calculate Value to store file locations as strings for use in model variables and outputs, and am having an issue with the model either hanging on to the first value it calculates for each, or not using the value properly later.

For example, my first model takes an input raster (Input DEM), parses its path (stores as DEMdirstr), feeds the path to a calculate value (expression = r"%DEMdirstr%"; not using the "r" would give us issues with files starting with "t"), which outputs the value as a folder data type to be used in Create Directory (which won't take DEMdirstr on its own), and the value from Create Output Directory is HYA_Workspace, which we attempt to use as in inline variable in output names throughout the model.

phase 2 of our process

If I run the model by double-clicking it and supply parameters in the dialog box it will create the directory, but the first geoprocessing tool (Pit Remove) will fail because the inline variable for %HYA_Workspace% is being returned as a "1".

Executing (Pit Remove): PitRemove I:\InterpolationResearch\t03\TTR\t03dem.tif 12 1\P2v1_q02\q02_fel.tif

If I run the model by supplying the locations within the model it will complete, but it was ALWAYS use that first value calculated for HYA_Workspace. It will not recalculate that value.

We feel like we've been careful to set preconditions as appropriate. I don't understand why the directory creation would work, but then the directory created couldn't be used by the next step in the model. I'm hoping there's a simple solution we're missing.

  • 1
    The value of '1' is the return code for the function (which I assume is Create Folder) this function does not return the folder it created only a numeric value (success/failure/error code). Instead of linking %HYA_Workspace% to pit remove use Calculate Value to get the full path (%DEMdir% + "\\" + %FolderName%) and use Create Output Directory as a precondition to Pit Remove. – Michael Stimson Jul 6 '15 at 22:03
  • @MichaelMiles-Stimson, this lead me to the right answer, though the the final format of the expression in the calculate value you suggested had to be r"%DEMdir%"+"\\"+r"%Folder Name%" to (again) avoid issues with "\t" in paths. If you would like to post this as an answer I'll accept it! Thanks! – troubbble Jul 7 '15 at 22:57
  • Consider answering your own question troubbble based on my comment with your own experience and working model for the benefit of future users. – Michael Stimson Jul 9 '15 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.