VEX foreach question.

   4052   5   1
User Avatar
Member
1111 posts
Joined: Aug. 2008
Offline
Now I am no VEX expert but is it possible to do something similar to ..

foreach(int num, @name) {}

assuming you have the name attribute setup in the incomming geo ofcourse.
/M

Personal Houdini test videos, http://vimeo.com/magnusl3d/ [vimeo.com]
User Avatar
Member
9380 posts
Joined: July 2007
Offline
int n = nuniqueval(0, “primitive”, “name”);
for (int i=0;i<n;i++)
{
string name = uniqueval(0, “primitive”, “name”, i);
//do something
printf(“%g\n”, name);
}
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
1111 posts
Joined: Aug. 2008
Offline
Haha it always ends up beeing you Tamte that answer ! Thanks will give it a go !
/M

Personal Houdini test videos, http://vimeo.com/magnusl3d/ [vimeo.com]
User Avatar
Member
1111 posts
Joined: Aug. 2008
Offline
hmm can't find any syntax that does the next thing I want, for simplicity lets say I want to randomly color each piece as it goes through them in the loop ?
/M

Personal Houdini test videos, http://vimeo.com/magnusl3d/ [vimeo.com]
User Avatar
Member
9380 posts
Joined: July 2007
Offline
well, you are not looping over geometry of each piece, but over uniue list of names for each element so you can do in prim wrangle for example:
int n = nuniqueval(0, “primitive”, “name”);
for (int i=0;i<n;i++)
{
string name = uniqueval(0, “primitive”, “name”, i);
if (name == @name) @Cd = random(i);
}

but it really depends on what you are doing
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
1111 posts
Joined: Aug. 2008
Offline
*doh* it was as simple as if (name == @name) ..

well..what I would like in the end is something like deleting all the other mesh but the current piece so point numbers etc get re-arranged to 0-$N for each piece while in that itteration.
/M

Personal Houdini test videos, http://vimeo.com/magnusl3d/ [vimeo.com]
  • Quick Links