Weston Slater

weston.slater

About Me

Connect

LOCATION
Not Specified
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Material to SOP in object merge May 11, 2018, 7:30 p.m.

Absolutely! I'm still getting to grips with using python, so I appreciate any and all edits! Made the change in my scene code as well. Can't thank ya enough, you've saved me so much time

Material to SOP in object merge May 11, 2018, 7:02 p.m.

That worked! Thanks a bunch, I really appreciate it!! Here's the code for anybody else curious:

# Support multiple selected nodes
for n in hou.selectedNodes():

# Only operate on Obj Merge SOPs

    if n.type().name() == 'object_merge':

        # Set variables for our nodes
        p = n.parent()
        m = p.createNode('material')
        objnode = hou.node(hou.parm(n.path()+"/objpath1").eval())

        # Connect the material sop to the obj merge sop
        m.setInput(0,n)
        
        # Move it below the merge node
        m.moveToGoodPosition()
        
        # Point the material sop to the obj's material
        if objnode.type().name() != 'geo':
            objnode = objnode.parent()
        
        hou.parm(m.path() + "/shop_materialpath1").set(hou.parm(objnode.path() + "/shop_materialpath").eval())

Edit by ndickson: Removed an indent that would have skipped Geometry objects.

Material to SOP in object merge May 11, 2018, 6:44 p.m.

I actually just caught that! Though unfortunately, it's still throwing a NoneType error for line 17; though this time it's claiming that “eval” doesn't exist?

Thanks again!