How can I catch a return Value from “Calculate Value” to start another Tool in ArcGis Model builder?

1729
2
04-08-2016 12:39 PM
MaxWeissenborn
New Contributor

Hey I have troubles with If/else statements in ArcGis Modelbulider. I have imported TauDEM Toolbox to work with D-infinity algorythm. Since D-Infinity only works with .tif raster files

I wanted to check first if the input raster is an .tif raster. After checking i want to start either D-infinity if the return value is true. If its not i want to convert it.

For that i tried to use the "Calculate Value" Tool with that code

Expression:

check_if_Tiff("%DGM%")

Codeblock:

    def check_if_Tiff(DGM):

    import arcpy

    desc = arcpy.Describe(DGM)

    type = desc.format

    if type == "TIFF":

        return "true"

    else:

        return "false"

so far so good but i dont know how to catch the return values to use them in another tool. I also dont understand what for is the tool "Merge Branch" cause i only get one return value

I read this documentation https://blogs.esri.com/esri/arcgis/2011/06/06/modelbuilderifthenelse1/ but i cant completely follow it. Do I have to do this with an python script or is there a way

like I am trying?

0 Kudos
2 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Rather than going to great lengths to check for all possible things that can go wrong, or provide options as you go, wouldn't it be easier to

  • ensure that the output from one section to the other is the required type by setting it as the output default
  • if certain requirements are required at the start of the process do the limit checking script there

This might make the flow easier

0 Kudos
FreddieGibson
Regular Contributor II

ModelBuilder doesn't provide a functionality to implement if-then-else logic out of the box. You would have to leverage python to implement this, but there are several approaches you can take. Try taking a look at the following page to see if this may be easier for you to implement.

Using If-Then-Else logic for branching—Help | ArcGIS for Desktop