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>

You may also like


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /homepages/23/d506891733/htdocs/app506892377/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048