Thursday 21 December 2017

Using Python script as precondition in ArcGIS ModelBuilder?


I have a model that has two preconditions, in which I need to figure out if there is a way to prioritize one precondition to 'run' prior to the second. Is anyone aware of any built-in ability to do so with Model Builder or that can suggest a work around?


For instance, if I try to 'link' one precondition to another, I get the error "Can only connect a variable to a process", this is because my 'output' has a precondition that a python script needs to be run against it first, and then that output has the second precondition executed (but only once the original output has been altered by the Python script).


enter image description here



Answer



Can you link the first precondition to the second precondition (so the first precondition must be true before the second fires) then link both (or just the second) to the final process?


Perhaps you can use If-Then-Else logic as output from your "Sum Field Insert New" process, and then link the output variable as the precondition to 'Altered Input?"



In ModelBuilder, if-then-else logic can be implemented by writing a script tool that tests some condition, then outputs two Boolean variables that describe the true and false condition and incorporating this script tool in a model. As an alternative to writing a script tool, you can also use the Calculate Value tool to test the condition and output a Boolean.


... One of the key steps in using branching logic in ModelBuilder is setting one of the conditional outputs as a precondition to further processing.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...