VEX : Create groups based on prim attribute value

   3641   2   1
User Avatar
Member
31 posts
Joined: July 2015
Offline
I'm attempting to process a bunch of .objs coming out of Maya that had material assignments at the face level.

After import, there's a “shop_materialpath” attribute attached to the primitives that corresponds to each shading group. What i'd like to do is create a group for each one of these unique “shop_materialpath” values so that I can easily reconstruct the material assignments in Houdini. Alternatively, I'd want to automate the creation of multiple blast nodes for each unique value for further processing but that seems like it would require python.

I was able to figure out this VEX function that will return all the material values:

s@materials = prim(0,“shop_materialpath”,@primnum);

I assume this is the function I'd need to use to create the actual groups:

setprimgroup(0,“test”,1,“set”);

What i'm not able to figure out is how I would link these together. I assume I would need to somehow loop over the values of the “shop_materialpath” and create groups based on that name but I'm having a hard figuring out how this would actually work.

Any guidance would be much appreciated.
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
hello,
the partition sop might be of any help?

https://www.sidefx.com/docs/houdini/nodes/sop/partition.html [www.sidefx.com]
User Avatar
Member
118 posts
Joined: Dec. 2013
Offline
There is another thread with a solution to this topic. I hope this helps. https://www.sidefx.com/forum/topic/73565/?page=1#post-310947 [www.sidefx.com]
Edited by GlenD - April 13, 2021 07:26:42
  • Quick Links