Jump to content
Sign in to follow this  
anicg

Python: create and assign material to each display flagged object based on name of object

Recommended Posts

I'd like to create and assign materials using the object names, for objects that have the display flag on, each object gets a principled shader created using its name and assigned to it

Share this post


Link to post
Share on other sites

this should get you started

matnet = hou.node("/mat")
objs = hou.node("/obj").recursiveGlob("*", filter=hou.nodeTypeFilter.Obj)

for obj in objs:
    if obj.type().name() == "geo" and obj.isDisplayFlagSet():
        safename = "_".join(obj.path().split("/")[2:])
        mat = matnet.createNode("principledshader", safename)
        obj.parm("shop_materialpath").set(mat.path())
    matnet.layoutChildren()

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×