1

I am using ArcGIS 10.2 for Desktop.

I have a model which contains several branches, which branch should run is based on the results of an earlier stage in the model. If the first stage of the model returns a Null result Branch A should run otherwise Branch B should run. I check for a Null result by using the Get Raster Properties tool ALLNODATA type.

At the start of each branch I created a Calculate Value tool which checks the Get Raster Properties and returns a 1 or 0 based on if that branch should run, and then uses the output as a precondition for the rest of the branch.

This sort of works but once the tool has been run once the various outputs are pre-set and instead of running the "Get Raster Properties" and "Calculate Value" tools again ModelBuilder jumps over to run the branches which meet their preconditions.

Is there a way to set all the results of Calculate Value to 0 before each run of the model so that branches are not run until the Calculate Value tool has run?

  • Can you upload a screen shot of the model as is? – Hornbydd Nov 25 '15 at 15:57
1

I eventually solved this by writing a python script and importing it into the model.

# Import ArcPy module
import arcpy
# Define Parameters
checkB = arcpy.GetParameter(0)
checkDB = arcpy.GetParameter(1)
PosYes = arcpy.GetParameter(2)
PosNo = arcpy.GetParameter(3)
NegYes = arcpy.GetParameter(4)
NegNo = arcpy.GetParameter(5)
# Run Checks
if checkB == 1:
  PosYes = 0
  PosNo = 1
else:
  PosYes = 1
  PosNo = 0
if checkDB == 1:
  NegYes = 0
  NegNo = 1
else:
  NegYes = 1
  NegNo = 0
# Output Results
arcpy.SetParameter(2,PosYes)
arcpy.SetParameter(3,PosNo)
arcpy.SetParameter(4,NegYes)
arcpy.SetParameter(5,NegNo)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.