Hello, im trying to build a model that iterates feature classes until one of the feature fulfill a condition. The problem is i dont know how to stop the model from further iterations. I tried while but i couldnt figure it out.
Solved! Go to Solution.
A general observation - when folks find they need to use iterators with conditions, that often is the point they end up going to Python scripting instead of Modelbuilder.
That said, there are some options in Modelbuilder to do what you are looking for. But Modelbuilder is limited in this regard. It will depend in part on how complex a condition is that you want to trigger the end of the run and whether the data is structured to support this.
Some possibilities:
Chris Donohue, GISP
These two articles suggest the same thing: nest a model within a model....
https://community.esri.com/thread/163666
I saw this but it doesnt solve my problem. There could be many features that fulfill the conditon but i want it to stop after first one. That the model output is only that one first feature.
It can be done in python, but that's probably not going to help you either...
A general observation - when folks find they need to use iterators with conditions, that often is the point they end up going to Python scripting instead of Modelbuilder.
That said, there are some options in Modelbuilder to do what you are looking for. But Modelbuilder is limited in this regard. It will depend in part on how complex a condition is that you want to trigger the end of the run and whether the data is structured to support this.
Some possibilities:
Chris Donohue, GISP
Thanks everyone for help. I have mange to do this like that. I know it doesnt look pretty but it works. Is it possible to put select by location or attribute after iterate feture classes so i dont have to add every one layer to the model? Even if i tried to make via submodel i still cloudnt integrate select by location with submodel output.
I finally figured out how to do what i wanted from the begining.
What a good solution. I was thinking you could use Calculate Value to test your condition (return true and false) and making that a precondition to the first tool in your processing chain (Make Feature Layer). This of course wouldn't stop the iterator but would keep anything from happening after the condition became true. Stop is a much better solution.