Skip to content

Instantly share code, notes, and snippets.

@cgcris
Last active February 29, 2016 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgcris/ac9e1d254164d9e8909b to your computer and use it in GitHub Desktop.
Save cgcris/ac9e1d254164d9e8909b to your computer and use it in GitHub Desktop.
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