Community
Bifrost Forum
Welcome to the Bifrost Forum. This is the place for artists using Bifrost to ask and answer questions, browse popular topics, and share knowledge about creating effects procedurally using Bifrost. You can also visit the Bifrost Community on AREA to download an array of ready-to-use graphs, read Bifrost news and updates, and find the latest tutorials.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

do_while question

1 REPLY 1
SOLVED
Reply
Message 1 of 2
g2m.agent
295 Views, 1 Reply

do_while question

I read this post about iteration and tried the do_while loop by myself, but I was confused.

https://forums.autodesk.com/t5/bifrost-forum/how-to-increment-a-value-inside-iterator-or-for-each-lo...

 

My graph should look like this:

 

 

 

v=5
i=1
while v<20:
    if i>5: break
    v+=v/2
    i+=1	
print v
# result: 22

 

 

 

but my graph gives me: 33

maya_Ld5VjuhKBMr.png

 

 

1 REPLY 1
Message 2 of 2
mjcg91
in reply to: g2m.agent

The loop_condition control if the loop will iterate again after the current iteration, not if it should start processing the content of the loop, so the output values are pulled even if loop_condition is false. Let's break this down:

 

at iteration n°4, value = 15, so it will loop again after the current iteration. you add 7 to 15 so the output =22.

at iteration n°5, value = 22, so it will stop looping after the current iteration. you add 11 to 22 so output = 33.


So the final value is 33, which is correct.

 

Here's what you can do:
do_while_02.jpg

 

do_while_03.jpg

Maxime Jeanmougin - Technical Artist
https://maximejeanmougin.com

Join the Bifrost Addicts community on Discord:
https://discord.gg/bifrost-addicts

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report