Vop array and for-loop. Cannot make it work. Always returns 1 item array.

   3179   6   2
User Avatar
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!
Edited by Andr - March 13, 2019 05:52:47

Attachments:
Q_vopLoop.hiplc (111.5 KB)
voploop_setup.JPG (122.0 KB)

User Avatar
Member
9380 posts
Joined: July 2007
Offline
https://www.sidefx.com/tutorials/h15-masterclass-loops/ [www.sidefx.com]
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
899 posts
Joined: Feb. 2016
Offline
you got me, I was a little lazy this time.
Will watch the video

cheers
User Avatar
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

Attachments:
Q_array_forloop_hip.hiplc (80.0 KB)
arrayloop.JPG (57.1 KB)

User Avatar
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)
User Avatar
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
User Avatar
Member
67 posts
Joined: April 2018
Offline
Andr
But still, the curiosity on how to make it work with a sop for-loop remains
This way works, by using a Block Begin set to Fetch Feedback.
Edited by pabcou - June 16, 2019 15:36:57

Attachments:
Q_array_forloop_hip__reply.hiplc (84.9 KB)
hindie_2019-06-16_21-18-47.png (30.6 KB)

  • Quick Links