Skip to content

Instantly share code, notes, and snippets.

@cgcris cgcris/clone node
Last active Feb 29, 2016

Embed
What would you like to do?
import hou
import os
objNode = hou.node('/obj')
outNode = hou.node('/out')
if len(hou.selectedNodes())>0:
for eachNode in hou.selectedNodes():
originalNodename = eachNode.name()
nodetype = eachNode.type().name()
# check what kind of node it is
if nodetype == "ifd":
newNode = outNode.createNode("ifd", "foo")
if nodetype == "geo":
newNode = objNode.createNode("geo", "foo")
# Call original nodes ex and make them black
eachNode.setName("ori_" + str(originalNodename));
nodeColor = hou.Color((0.0, 0.0, 0.0))
eachNode.setColor(nodeColor)
newNode.setName(originalNodename);
# Loop original params and transfer them
for eachParam in eachNode.parms():
parmName = eachParam.name()
parmValue = eachParam.eval()
#Transfer values to new node
newNode.parm(parmName).set(parmValue);
#copy expressions if they exist
try:
exp = eachParam.expression()
newNode.parm(parmName).setExpression(exp, hou.exprLanguage.Hscript);
except:
pass
else:
print "nothing is selected"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.