Vop array and for-loop. Cannot make it work. Always returns 1 item array.
3179 6 2-
- Andr
- Member
- 899 posts
- Joined: Feb. 2016
- Offline
Hello,
Inside a Primitive Vop, for each prim I want to have an array attribute populated with a number of noise values.
This is my setup, but I cannot append subsequent values of the iteration. The array keeps staying at 1 len.
Any ideas about what am I doing wrong?
Thanks a lot!
Inside a Primitive Vop, for each prim I want to have an array attribute populated with a number of noise values.
This is my setup, but I cannot append subsequent values of the iteration. The array keeps staying at 1 len.
Any ideas about what am I doing wrong?
Thanks a lot!
Edited by Andr - March 13, 2019 05:52:47
-
- tamte
- Member
- 9380 posts
- Joined: July 2007
- Offline
-
- Andr
- Member
- 899 posts
- Joined: Feb. 2016
- Offline
-
- Andr
- Member
- 899 posts
- Joined: Feb. 2016
- Offline
tamte
https://www.sidefx.com/tutorials/h15-masterclass-loops/ [www.sidefx.com]
I've watched the masterclass but nothing really clicked in my mind.
I have now a similar issue, but this time with a normal for loop (non-vop context).
I'm iterating over connected pieces and I want to populate an array with the number of primitives for each connected piece.
the code I'm using in the wrangle is the following:
append(i[]@store_nprims , nprimitives(1)); //setdetailattrib(0, "store_nprims", nprimitives(1) ); // this also doesn't work int iter = detail(2, "iteration", 0); // debug printf(" %i ", iter); // debug
The size of the array doesn't expand, it's being populated only with the last iteration value.
Bonus question: in this 3 iterations loop, the output of the print function is (2, 0, 1, 2). It prints out 4 times (instead of 3), beginning with a duplicate of the last iteration. Why is that?
Thanks for any help,
cheers
Edited by Andr - June 4, 2019 08:29:29
-
- Andr
- Member
- 899 posts
- Joined: Feb. 2016
- Offline
Andr
Bonus question: in this 3 iterations loop, the output of the print function is (2, 0, 1, 2). It prints out 4 times (instead of 3), beginning with a duplicate of the last iteration. Why is that?
I guess this is because the wrangle read the ‘cached pass’
If I hit the ‘reset cached pass button’ the print function output the correct series (0,1,2)
-
- Andr
- Member
- 899 posts
- Joined: Feb. 2016
- Offline
Andr
I'm iterating over connected pieces and I want to populate an array with the number of primitives for each connected piece.
A workaround is to do everything inside a single detail wrangle with a for loop that uses the function findattribvalcount(0, “prim”, “class”, “class_value”) and append the result to an array at each iteration.
But still, the curiosity on how to make it work with a sop for-loop remains
Edited by Andr - June 4, 2019 13:47:35
-
- pabcou
- Member
- 67 posts
- Joined: April 2018
- Offline
-
- Quick Links


