a list of group names to integer attrib

   3058   2   0
User Avatar
Member
343 posts
Joined: Dec. 2014
Offline
I need to turn a list of groups into an integer point attrib: group0, group1 group2, etc. in VEX Is there a function that turns strings into integers? or perhaps there's a better way that doesn't rely on numbered groups, maybe storing the list of groups in an array and iterating through it? Any advice is much appreciated!
User Avatar
Member
5125 posts
Joined: Feb. 2012
Offline
You can use the random_shash function:

i@groupid = random_shash ( mygroupname );
Edited by animatrix_ - Aug. 29, 2017 12:55:29
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
User Avatar
Member
8184 posts
Joined: Sept. 2011
Offline
if you want contiguous index numbers, you can pass your list of groups as a string parm. This would require the list of groups is persistent and non-varying, and the groups are exclusive.

// Assuming groups are exclusive
int @class = -1;
string group_list;
string groups[];
group_list = chs("group_list");
groups = split(group_list);
foreach( int index; string grp; groups ){
if( inpointgroup(0, grp, @ptnum ) ) {
@class = index;
break;
}
}
  • Quick Links