array attribute to use in LOP for loop

   302   2   1
User Avatar
Member
39 posts
Joined: March 2014
Offline
Hi,
I have several work_items containing each an attribute called "variant". Then I have a WaitForAll TOP set to conserve unique values for that attribute. I end up with a single work_item, and a array of values in the attribute. Then this is fed in a ROP_USD_Output node, where I need to loop over the variants (because they all need to end up in the same USD file).

In the LOP tree, I have a ForEach_End node with its iteration method set to Each String In Parameter. I tried using `@variant` directly, but that didn't work. I only get the first variant. How can I expand the array to be recognized by the loop node?

Thanks!

F
tpetrick
Staff
523 posts
Joined: May 2014
Offline
Using @attrib is the same as using @attrib.0 -- it acceses the first value in the attribute. You'll probably need to use one of the PDG expression functions instead of the @shorthand form.

For example, you can use pdgattrib(..) to read an attribute value at specific index, such as pdgattrib("variant", 2) to access the variant attrib at index 2. If you're accessing a string attrib you'll need to use pdgattribs instead, with an "s" on the end. Since the for each LOP creates an index variable for you, your nodes inside the loop can use pdgattrib("attribname", @ITERATION) to access an attribute for the current iteration.

Alternatiely, you could also use pdgatribvals("variant"), which returns a space-separate string containing all values in the PDG attribute with that name (https://www.sidefx.com/docs/houdini/expressions/pdgattribvals.html). That should be the correct format for the Iterate Over Strings parm on the for each LOP.
User Avatar
Member
39 posts
Joined: March 2014
Offline
Thanks Taylor,

pdgattribvals("variant") is exactly was I needed.
  • Quick Links