for-each loop with stop condition?

   5398   7   0
User Avatar
Member
1075 posts
Joined: 4月 2017
Offline
Hi!

If I want to iterate a number of times but I want to stop if a condition is met. For example, lets say I want to stop once the geo's bounding box is too big. Any ideas?

-Olivier
User Avatar
Member
8833 posts
Joined: 7月 2007
Offline
usually you generate detail attribute in a separate branch within for loop and then just reference it in a stop condition, if the resulting value is not 0 it will break out of the loop
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
1075 posts
Joined: 4月 2017
Offline
Ahh!

Thanks tamte!

-Olivier
User Avatar
Member
1075 posts
Joined: 4月 2017
Offline
Am I correct If I say that triggering the stop condition (1) will void the current iteration and only keep the previous result? …Or does it simply stop from going back to the begin node?

I'm asking because my setup seems to stop one iteration too early.

-Olivier
User Avatar
Member
8833 posts
Joined: 7月 2007
Offline
yes, the stop condition is evaluated before the iteration is run and if it's true, the iteration is not run
you can always pass the detail attribute you are using for condition from the previous iteration, and reference it from the start of the iteration so that it's evaluated at the start of next iteration to get the result you want
Edited by tamte - 2019年2月28日 14:29:53
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
1075 posts
Joined: 4月 2017
Offline
I did just about the same thing you described and it fixed my problem.

Thanks!

-Olivier
User Avatar
Member
1075 posts
Joined: 4月 2017
Offline
Uploading an example.

Attachments:
StopCondition.hipnc (125.0 KB)

User Avatar
Member
27 posts
Joined: 12月 2016
Offline
olivierth
Uploading an example.
Thanks for the file,Olivierth.
Edited by aaryanguna - 2023年1月7日 00:50:38
  • Quick Links