[Sidefx-houdini-list] Point promotte per class ?

Julian Johnson julianjohnson1962 at gmail.com
Thu Dec 29 07:29:24 EST 2016


On 27/12/2016 22:41, Olivier Jeannel wrote
> On a side note, if someone have a For Each Loop method either in VEX or
> VOP, to collect such datas (Get attribute from index 0 of each Primitive
> (@name Primitive) and SetAttribute it to every point of each Primitive.
> That would be usefull.
Hi Olivier,

Here's a piece of VEX to run in an Attribute Wrangle in Detail mode:

//Get number of unique piece names e.g. piece10
int n = nuniqueval(0,"primitive","name");
addprimattrib(0, "prim_mod", 0.0);

//iterate over each piece name
for(int i = 0; i<n; i++)
{
     //pull in each piece name
     int s = uniqueval(0,"primitive","name", i);

     //find number of polygons with that name
     int j = findattribvalcount(0, "primitive", "name", s);

     int index = findattribval(0, "primitive", "name", s, 0);
     int prpts[] = primpoints(0, index);
     int prpt = prpts[0];
     float piece_mod = point(0,"mod",prpt);

     //get each polygon with that name and iterate through them
     for (int k = 0; k<j; k++)
     {
         int found = findattribval(0, "primitive", "name", s, k);
         setprimattrib(0, "prim_mod", found, piece_mod);
     }
  }

There's also a .hipnc file here which shows it working:
https://dl.dropboxusercontent.com/u/69741069/island_promote.rar

Not sure if this does what you want but it was fun writing it. If it 
does do it, I'd be interested to see if it is any quicker.
J





More information about the Sidefx-houdini-list mailing list