Im attempting to traverse a line with multiple points using a foreach loop sop network via
an attributewrangle sop.
The attribute wrangle vex block is attempting to modifying custom point attributes in the line input node.
Its been very frustrating.
I cant seem to execute the attributewrangle vex code per point per foreach loop iteration.
The foreachloop knows how many points are in the input line.
Just getting the iteration value requires something like this
int iter = detail("op:../foreach_begin1_metadata1", "iteration");
Ive been trying to use getattrib and setattrib vex functions but not succeeding with the syntax.
Help with usage of attributewrangle in a foreachloop would be greatly appreciated.
foreach loop using attributewrangle per input point
4816 6 0- willanielewicz
- Member
- 1 posts
- Joined: Sept. 2021
- Offline
- animatrix_
- Member
- 4693 posts
- Joined: Feb. 2012
- Offline
Hi,
You need to set the For Each block to Feedback mode.
You need to set the For Each block to Feedback mode.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- WillA
- Member
- 98 posts
- Joined: July 2005
- Offline
Even with the suggestion from @animatrix the attributewrangle still would not access
the iteration or value attributes.
Forum author bubblepins gave me a solution for this issue.
here is some sample Vex code in my scene.
the iteration or value attributes.
Forum author bubblepins gave me a solution for this issue.
when using an attributewrangle inside a foreach looop, you need to connect the "metadata" foreach node
(that extra foreach node that contains the iteration value)
and you need to connect that node to the second input of the attributewrangle
here is some sample Vex code in my scene.
int thisptnum = detail(1,"value",0); int thisvalue = thisptnum * 10; vector thispoint = point("../line","P",thisptnum); setpointattrib(geoself(), "n2", thisptnum, thisvalue, "set"); printf(" P=%f ptnum=%d value=%d\n",thispoint,thisptnum,thisvalue);
Edited by WillA - June 27, 2023 18:14:48
- animatrix_
- Member
- 4693 posts
- Joined: Feb. 2012
- Offline
You can do the same without connecting the meta node to attribwrangle node. You just have to add a spare parm pointing to the meta node and then using -1 for the detail function call:
detail ( -1, "iteration" )
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- WillA
- Member
- 98 posts
- Joined: July 2005
- Offline
animatrix_
You can do the same without connecting the meta node to attribwrangle node. You just have to add a spare parm pointing to the meta node and then using -1 for the detail function call:detail ( -1, "iteration" )
Could you please add more details to your suggestion.
Add a spare parm pointing to the meta node is a bit vague to me.
Connecting the meta node to the second input of the attributewrangle is a simple fix.
thanks
- HaniJahan
- Member
- 14 posts
- Joined: May 2021
- Offline
about the spare parm, these might be helpful
also I noticed that you might missed the last part of detail function
detail(surface_node, attrib_name, attrib_index)
yours is
detail("op:../foreach_begin1_metadata1", "iteration");
not sure but maybe adding a value for attrib_index will help with you're issue
also I noticed that you might missed the last part of detail function
detail(surface_node, attrib_name, attrib_index)
yours is
detail("op:../foreach_begin1_metadata1", "iteration");
not sure but maybe adding a value for attrib_index will help with you're issue
Edited by HaniJahan - June 28, 2023 12:50:24
- animatrix_
- Member
- 4693 posts
- Joined: Feb. 2012
- Offline
WillAanimatrix_
You can do the same without connecting the meta node to attribwrangle node. You just have to add a spare parm pointing to the meta node and then using -1 for the detail function call:detail ( -1, "iteration" )
Could you please add more details to your suggestion.
Add a spare parm pointing to the meta node is a bit vague to me.
Connecting the meta node to the second input of the attributewrangle is a simple fix.
thanks
Hannah covered it above me. In any case I would recommend watching Jeff Lait's For Loops masterclass that explains these concepts in detail:
Hannah Jahanshahi
about the spare parm, these might be helpful
also I noticed that you might missed the last part of detail function
detail(surface_node, attrib_name, attrib_index)
yours is
detail("op:../foreach_begin1_metadata1", "iteration");
not sure but maybe adding a value for attrib_index will help with you're issue
The last parameter is ignored so it's not necessary:
https://www.sidefx.com/docs/houdini/vex/functions/detail.html [www.sidefx.com]
"The last argument is always ignored. It is just there so you can change a prim/point/vertex call (which each have an element number argument) to a detail call by changing the name without having to change the arguments as well."
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
-
- Quick Links