1

In ArcGIS ModelBuilder, is it possible to create a variable (that can be used as a precondition for following tools) that tells if an iteration has been finished?

Example: An iterator buffers all feature-classes in a file-geodatabase and creates an output for each of that feature-classes. After all feature-classes have been buffered, I want to run a new tool.

How do I set the completed iteration as a precondition for that tool?

I'm not fluent in python.

enter image description here

enter image description here

2 Answers 2

2

My answer/comment in your original question (Action after iteration in ArcGIS ModelBuilder?) still stands, a fairly simple piece of python code will resolve this which returns a True or False value that you could use as a precondition.

An example would be:

Mode

The Calculate Value tool would be set up as:

calculate Value tool

It is simply checking that the number of feature classes in the output workspace matches the number in the input workspace.

The full python code block is this:

import arcpy
def test(inws,outws):
  # Count input featureclasses
  arcpy.env.workspace = inws
  infcl = arcpy.ListFeatureClasses()

  # Count output featureclasses
  arcpy.env.workspace = outws
  outfcl = arcpy.ListFeatureClasses()
  if len(outfcl) == len(infcl):
    return True
  else:
    return False

In my example I am sending the buffers to the IN_MEMORY workspace, you would need to change that to where your output is going. Do that by changing the text in the expression box.

5
  • This works so far, but one problem occured: The last feature class that's being iterated is not being buffered. ArcGIS says that it's being buffered successfully, but strangely no output appears. All the other feature classes are being buffered just fine. This always happens to the last feature-class (I tried multiple sets of feature classes, it's definitely not an issue with the shapefile). Oct 3, 2016 at 11:04
  • That sounds like odd behaviour, what version of ArcGIS are you using? Try rebooting your machine?
    – Hornbydd
    Oct 3, 2016 at 13:23
  • I'm running ArcMap 10.3.1 Advanced. Rebooting didn't do anything. I mean, I can work my way around this, but still it is weird behaviour. Oct 3, 2016 at 14:02
  • Hmm not sure I can help at his point as it obviously works for me. Could it be something like the input dataset has no data in it or is being file locked? Anyway sounds like you have a work around.
    – Hornbydd
    Oct 3, 2016 at 15:21
  • I'll search for the reason and let you know if I find it. Thanks for the help, I really appreciate it! Oct 3, 2016 at 16:34
1

It can be achieved by integrating a model within a model. https://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/integrating-model-within-a-model.htm

it is not really a precondition you are diagramming but a nested model within another model. It is often referred to as a sub-model. I this case the red box (inside) is a sub-model. Your diagram is a little difficult to see the interaction between the models but appear to need to collect the values from the top area outside the red box.

This is a good pointer Problems Integrating Sub-Model into Master Model

2
  • I know that what's inside the red box is a submodel that's nested in another model. My problem is that that submodel does not create any value that tells me if it's finished buffering all the feature-classes. But the "New Tool" shall not be run before all feature classes have been buffered. Oct 2, 2016 at 15:49
  • I added another screenshot that hopefully makes it clearer. Oct 2, 2016 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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