[Sidefx-houdini-list] Point promotte per class ?
facialdeluxe at gmail.com
Mon Jan 2 06:49:29 EST 2017
Sorry for the late reply (beeing on and off during new year)
First thing first, a big thank you !
This is what I was after.
The loop inside the loop is way above my vex skills, and I'm still trying
to understand the uniqueval command.
I'm getting slightly different results with the 2 methods. No big deal. I
guess this might be because of the way attributes are promoted internaly in
polysoup and in your wrangle.
And I think the wrangle method is faster, thought I don't know how to
2016-12-29 13:29 GMT+01:00 Julian Johnson <julianjohnson1962 at gmail.com>:
> 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;
> 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:
> 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.
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
More information about the Sidefx-houdini-list