Jump to content

Returning each n iteration of a vex for loop


Wideeagle

Recommended Posts

Hi everyone I am encoutering an issue with a VEX code.  I want to offset a lot of uv island correctly on different UDIMS.  So here’s the idea.    
 

I have a wrangle inside a for each loop.  For the y offset its ok I do:

———————————-  

//getting current iteration of the for loop  

int iteration = int(detail(1,"iteration");

@yiter = iteration%chi(‘scale’);  

———————————-

 So if scale is equal to 5 my y offset will be like that:  

@yiter=1 for island 1

@yiter=2 for island 2  

[...]  

@yiter=5 for island 5  

@yiter=1 for island 6

[...]  

@yter=5 for island 10

 etc.... the value reinitializes itself each n iterations.  (n defined by my chi(‘scale’)  

 

Now for the x, I want it to be incrementing like that:  each time @yiter = 10 xiter = xiter + 1  
 

So it gives

 yiter=1 xiter=1 for island 1  

yiter=2 xiter =1 for island 2  

[...]  

yiter=5 xiter=2 for island 5  

[...]  

yiter = 10 xiter = 3 for island 10    

 

so xiter counts how many times yter is reaching chi(‘scale’)   and it needs to work for any given scale.

 

 Here is what I tried:  On input 1 I have my metaimport node.    
 

 —————————-

 int Scale = chi('Scale');

int nbloop = int(detail(1,"numiterations")); //total num of iterations for each island  

i@xiter = 0; //init xiter  

for (int i=0; i < nbloop;i++)

{    
     if(i%Scale == Scale-1)    

     {      
       i@xiter += 1;

      }

 }  

——————————    

 the thing is that in the end it gives me the total number of 10 iterations ( if I iterate 100 times then xiter=10 but I cant acces xiter each time it does the loop only after it looped nbloop times.    

Do you have any idea how can I get xiter at each incrementation?  Tell me if you need me to be clearer.  Thanks a lot !    

Edited by Wideeagle
Link to comment
Share on other sites

6 hours ago, Wideeagle said:

but I have a huge number of pieces and I want to organize them on specific udims (lets say for example 10 pieces on 10 udims) thats why I need to iterate 

you can assign different i@udim prim attribute value to each of them based on the island index (what are you curently iterate over? class attribute? name? )

do you have some simple hip showing your issue?

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...