Select to view content in your preferred language

For & While iterators in model builder

3017
1
07-07-2017 12:17 AM
TomTester1
Deactivated User

Hi,

My aim is to construct a simple model consisting of main model (Model), sub-model with while loop (SubModelWhile) and sub-model with for loop (SubModelFor). The task of the Model is to filter surface.tif for n times (starting from 1) and write value collected from resulting .shp down and evaluate the value in if clause with the value from previous round (so model runs minimum two rounds). Model continues adding rounds for the SubModelFor until the condition in while loop is satisfied, when the condition is satisfied SubModelWhile returns the resulting .shp from the previous filtering round (n-1).

There are several general problems that I have looked answer for,

1) For me it is difficult to understand the logic how you feed and return values to/from submodels.

2) SubModelFor is not able to just simply overwrite the previous iteration of filtered.tif. I have Geoprocessing Options -> Overwrite ticked.

3) Visual problems with model builder diagrams. Often I have to navigate to Diagram Properties --> Symbology, change style from 1 to 2 or vice versa, to correct the visual looks of the model. Is there any permanent solution?

4) What would be the tool to write down the amount of rows in shapefile and compare it to previous iteration in while clause?

The picture attached has just the conceptual model from what I would want to create.

0 Kudos
1 Reply
curtvprice
MVP Alum

I think one thing you may not be getting is that each iterator needs to be in a submodel and return the iteration results in a multi value parameter created with the Collect Values tool. The help does have quite a few good examples.

A quick tour of advanced techniques in ModelBuilder—Help | ArcGIS Desktop 

I recommend this set of blog posts too -- they really have helped me.

If You Are Stuck At If

It should be said that if things get really complicated it may be time to think about learning more about Python scripting. Model Builder is very powerful and can do a lot -- but it is limited when conditional logic and looping get complex. I mean, I'm convinced you can do some pretty complex things but in the end it may be easier to move to Python than deal with many nested models.

0 Kudos