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>

Assign Material to Selection

All Maya and Softimage Guys know the option “Assign to Selection”. Here is the Houdini equivalent ;). Just copy/paste this code into the this file: C:\Users\USER\Documents\houdini17.0\OPmenu.xml

Node: if there is no file yet, just create one. Houdini should pick it up on the next startup. And as you see, currently it works exclusively for redshift materials and the standard principed shader. If you want to use other shader types add them to the oShaderTypes variable.

<?xml version="1.0" encoding="UTF-8"?>
<menuDocument>
    <menu>
        <scriptItem id="Util_AssignMaterialToSelection">
            <label>Tools: Assign Material to Selection</label>
<scriptCode><![CDATA[
import hou
shader = kwargs.get("node", None)
oselectedNodes = hou.selectedNodes()
oShaderCheck = 0
oShaderTypes = ["redshift::Material", "principledshader::2.0", "redshift_vopnet", "material" ]
oShaderType = str(shader.type().name())


for item in oShaderTypes:
    if oShaderType in item:
        oShaderCheck = 1

if oShaderCheck == 1:
    for oNode in oselectedNodes:
        if str(oNode.type().name()) == "geo":
        	#print "assign" + str(shader.path()) + " to " + str(oNode.path())
        	oNode.parm("shop_materialpath").set(shader.path())


]]></scriptCode>

Retiming Stuff (the old way)

Hey, last week I had the case that I had to do some liquid retiming within Houdini 16.5. Meaning, that there is no proper retime SOP as in Houdini 17. So I did it the classical way with findattrib. If you are in Houdini 16.x this is definitively a way to check out. I have attached an image of my tree. It works really nice, also with changing pointcounts. The only thing that I had to care about was to save an id attribute within my flip simulation.