Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am struggling to get the ArcGIS ModelBuilder "While" Iterator to work as I would expect it. I have a hunch it's user error, but even reading the help hasn't seemed to get it working for me.

I have a simple model that calls a Python script that simple does a time.sleep(15) and then sends back the conditional parameter of "TRUE" or "FALSE" using arcpy.SetParameterAsText(1, "FALSE") or similar for True statements in an if/else statement. I've also tried every combination of TRUE, True, and true, as outputs from my Python script without success.

Model with WHILE Iterator

I can see in the results that my conditions are being set correctly:

Executing (While): IterateCondition FALSE TRUE
Start Time: Tue Nov 20 16:10:06 2012
Succeeded at Tue Nov 20 16:10:06 2012 (Elapsed Time: 0.00 seconds)


Executing (While): IterateCondition TRUE TRUE
Start Time: Tue Nov 20 16:26:41 2012
Succeeded at Tue Nov 20 16:26:41 2012 (Elapsed Time: 0.00 seconds)

but the WHILE Iterator continues to fire the sleep script, even if I change the output parameter of my script. Any ideas on why I cannot seem to get the sleep script to stop firing? What should I be passing from my SetParametersAsText() in order to get the While Iterator to stop firing the Sleep script?

share|improve this question
up vote 4 down vote accepted

The input of the While loop should be of boolean data type.

I recreated your model and script and called arcpy.SetParameterAsText(1, "FALSE") in the script. For the script output, I used a boolean. ModelBuilder automatically converts the output string "FALSE" to boolean false. The boolean false can be evaluated by the While loop.

share|improve this answer
I was sure it was something simple like that, but for the life of me I couldn't get it to work correctly. Setting the script output to "Boolean" and "Derived" worked great and now the model and While Iterator are working as expected. Thank you so much! – RyanDalton Nov 21 '12 at 15:14
NOTE: I previously had my output variable set to "string", hence the problem. – RyanDalton Nov 21 '12 at 15:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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