Select objects with this material

Like the “Assign Material to Selection” function, all Softimage/Maya Guys know the “Select objects with his martial” button. I know this is already an option under the material palette. But who uses this? So here is the code to get the same functionality in Houdini. Just copy/paste the code into this file: C:\Users\USER\Documents\houdini17.0\OPmenu.xml And you are done. On the next houdini restart it should pop up on the right mouse button menu.

 

<?xml version="1.0" encoding="UTF-8"?>
<menuDocument>
    <menu>
        <scriptItem id="TM_Util_SelectObjectsWithThisMaterial">
            <label>TM Tools: Select Objects with this Material</label>
<scriptCode><![CDATA[
import hou
oselectedNodes = hou.selectedNodes()
oShaderTypes = ["redshift::Material", "principledshader::2.0", "redshift_vopnet", "material" ]

for mats in oselectedNodes:
    oShaderCheck = 0
    oShaderType = str(mats.type().name())
    for item in oShaderTypes:
        if oShaderType in item:
                oShaderCheck = 1
    #print mats.name()
    if oShaderCheck == 1:
        oNodes = mats.dependents()
        mats.setSelected(0)
        for oNode in oNodes:
            if str(oNode.type().name()) == "geo":
                #print oNode.path()
                oNode.setSelected(1)

]]></scriptCode>
        </scriptItem>


  	</menu>
</menuDocument>

You may also like