Jump to content

Each x th iteration


Recommended Posts

Hey all,

I want to execute some operations every x iterations. Is there any simple way?

 

 

I just started learning Houdini, I tried a dumb method below. Although it seems to work, it will take more time... :blush:

As shown in figure 1, it's the beginning of an orange loop, I hope to do some check or delete operations in the green loop every 30 iterations of ORANGE.

 image.png.f723a73efdd36161bb29fd8046ae501b.png

This is the expression in switchif5, call the iteration of ORANGE and divide it by 30, then use round () to judge whether it is an integer. (Incidentally, how to judge whether it is an integer more concisely)
image.png.83d1a5fb4b20f7969a625356127050fc.png 

and if the bool result is ‘1’, means it's not 30/60/90th... iteration, so it will execute input1 and output nothing.   

And the same bool value ‘1’ will also be called in switchif6, so it will output without any operation in GREEN. 

And the ‘1’ will also be called at stop condition of GREEN end. so the GREEN will not run, too. (GREEN seems to run at least once before stop condition judging, but it runs with no data which output in switchif5) 

So does the calculation still take time even if run with empty data?

 

 

Thanks!

Edited by Elon
Link to comment
Share on other sites

you can try a modulo (%) to execute instructions every x iterations if your variable is an integer like :

if(integer%30 == 0, 1, 0)
 

in that case it will execute instruction every 30 iterations

 

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...