Assign material to primitive group?

   7232   6   2
User Avatar
Member
13 posts
Joined: May 2013
Offline
I have an imported obj that comes in as one geo object. It's a very large asset with a large number of primitive groups. My ultimate goal is to be able to assign different materials to a set of primitive groups. Is there a way to do that procedurally?

I'd like to break out the one geo object into multiple objects that can receive unique material assignments.

thanks for your time
User Avatar
Staff
5158 posts
Joined: July 2005
Offline
Use the Material SOP, it can assign any SHOP or material to any primitive group.
User Avatar
Member
13 posts
Joined: May 2013
Offline
awesome! I just saw that the groups dropdown lists all primitive groups in the object.

would you happen to know how to iterate over all primitive groups in python?

I have about 300 primitive groups and I'd like to write a little expression that loops through them all, and assigns certain materials to certain subsets? I know the basics of python in houdini and I can loop over objects and create new material sops but I'm not sure how to list all primitive groups on a given file node.

thanks!
User Avatar
Member
13 posts
Joined: May 2013
Offline
After digging around a bit in the HOM cookbook:
http://www.sidefx.com/docs/houdini13.0/hom/cookbook/print_hip_stats/ [sidefx.com]

I realized I could get the list of primitive groups in my object using this call:


myObj = hou.node('/obj/importedObj')
primitiveGroups = myObj.displayObject().geometry().primGroups()
User Avatar
Member
88 posts
Joined: Feb. 2021
Offline
Here to ask the same question but in the lops context.
User Avatar
Member
7770 posts
Joined: Sept. 2011
Offline
TangheStudent
Here to ask the same question but in the lops context.

There is a rough approximation called geometry subsets, which allow for assigning different materials to parts of the same mesh. Sop import can convert groups to geometry subsets automatically.
User Avatar
Member
88 posts
Joined: Feb. 2021
Offline
I indeed notices shortly after asking the question.

below is a screenshot

Attachments:
Screenshot from 2022-05-29 18-57-49.png (71.4 KB)

  • Quick Links