Jump to content
AdamM

Unable to accumulate detail attribute with for each loop

Recommended Posts

Hi.

I have a for each loop (looping over path) that reads primgroup details. If a prim is found to be part of a particular group I store the prim number in a string array detail attribute using setdetailattrib - append.
The string array is declared before the loop begins. I have checked each iteration of the loop using single pass and the values are being generated correctly (per loop).

I don't seem to be able to accumulate the values of the loop in the detail attribute. It will only remember the last iteration of the loop.

What am I doing wrong?

Thanks in advance.

houdinifx_jEYs4ZNZSF.png

Share this post


Link to post
Share on other sites

I think you need to set the attribwrangle to run over primitives.
I'm thinking that it needs to run over every primitive, so it changes the detail attribute each time.
Instead of detail which runs once, giving you one value.

Also, what is that attribcopy doing in the for-loop?
Isn't it overwriting the attribute you want to change?

Share this post


Link to post
Share on other sites

Hi,

If all you want is an array of elements in that group, you can use the expandprimgroup function:

QCSHxBf.png

  • Like 1

Share this post


Link to post
Share on other sites

That copy node was just one of the many attempts I made at trying to consolidate the information into the detail attribute, I shouldn't of posted it in the picture.

On the first pass of the loop I get the following prims [0, 2, 6, 9, 10, 12].
Second pass gives me an empty array (this is expected)
Third pass gives me [3, 4, 5, 15, 16, 23, 32, 68]

I want to exit the loop with the detail array having [0, 2, 6, 9, 10 12, 3, 4, 5, 15, 16, 23, 32, 68], but it only ever has [3, 4, 5, 15, 16, 23, 32, 68].

I simplified the case using the expandprimgroup function and tried both a detail and primitive loop.

The primitive numbers (and geometry) are changed on the right hand side of the graph, that is why I copy back them back to the left hand side.
I have worked out a way to get it working. I simply record the current primitive number as a primitive attribute and then later copy it back to a detail attribute.

Update. 
This got it working.
Turns out that each time the loop inputs with the per piece it clobbers the detail attrib.
A second loop input with feedback retains attribute.

Thanks for helping
 

kVRw0OUlRy.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×