選択したsopノードから、object merge nodeを作成するスクリプト
import hou
#get current selection
sel = hou.selectedNodes()
#create object merge nodes from selected nodes
def create_om():
#check if node is selected
if not len(sel)>0:
msg = hou.ui.displayMessage("please chose a node", buttons=('OK',), severity=hou.severityType.Warning)
return
col = hou.Color(0.75,0.15,0.5)
for i in sel:
cat = hou.nodeType(i.path()).category().name()
if(cat=="Sop"):
pos = i.position() + hou.Vector2(0,-1)
parent_path = i.parent().path()
om = hou.node(parent_path).createNode("object_merge")
om.setPosition(pos)
om.setName("IN_"+i.name(),unique_name=True)
om.setColor(col)
hou.node(om.path()).parm("objpath1").set("../"+i.name())
else:
pass
#create single object merge node from selected nodes
def create_om_combine():
#check if node is selected
if not len(sel)>0:
msg = hou.ui.displayMessage("please chose a node", buttons=('OK',), severity=hou.severityType.Warning)
return
cat = hou.nodeType(sel[0].path()).category().name()
if(cat=="Sop"):
col = hou.Color(0.75,0.15,0.5)
num = len(sel)
pos = sel[0].position() + hou.Vector2(0,-1)
parent_path = sel[0].parent().path()
om = hou.node(parent_path).createNode("object_merge")
om.setPosition(pos)
om.setName("IN_selectede_all",unique_name=True)
om.setColor(col)
hou.node(om.path()).parm("numobj").set(num)
for i,n in enumerate(sel):
hou.node(om.path()).parm("objpath"+str(i+1)).set("../"+n.name())
create_om()
#create_om_combine()