Hi,
I'm relatively new to the world of Python and would obviously like to start implementing slowly in my practice. I've created a small script that allows me to create an object_merge node from the selected node in my network.
Please feel free to correct my coding or suggest easier way of doing thigs. Very new at this whole Python thing
Here's my code :
#selectedNodes creates an array/list of the nodes that were selected.
nodes = hou.selectedNodes()
#Me node of interest is the first one in this case, hence nodes
#print nodes
name = nodes.name()
#We need to get the full path of where to create the new nodes
parent = nodes.parent()
path = parent.path()
#print parent
#print path
#We need to create the object merge node
objectMerge = parent.createNode(“object_merge”)
parm = objectMerge.parm(“objpath1”)
parm.set(nodes.path())
objectMerge.setName(“merge_in_” + name)
#Get mouse position and print
net_editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
#print net_editor.cursorPosition()
#print net_editor
objectMerge.setPosition(net_editor.cursorPosition())
I'm running into an issue where I can't use this more than once in my network since two nodes can't have the same name. So how do we solve this?
Thanks!