Q: - General Python help !

   3970   11   1
User Avatar
Member
2624 posts
Joined: 8月 2006
Offline
Hi,
Can anyone show me an example of how I can join nodes together for example a set of sop nodes in a for loop ie box > facet > null . I just dont quite get the syntax of how to have a list of nodes and wire one nodes output to another nodes input .

Kind regards

Rob
Edited by - 2015年3月21日 22:38:06
Gone fishing
User Avatar
Member
621 posts
Joined: 8月 2008
Offline
hey monkey i am not in houdini right now, you can do hou.node(nodethat will be below)setInput(0, thenodeyouwant)
User Avatar
Member
2624 posts
Joined: 8月 2006
Offline
Hi, I am specifically after being able to loop through a collection of nodes to connect them.
Gone fishing
User Avatar
Member
4 posts
Joined: 9月 2014
Offline


sel= hou.selectedNodes()

for n,i in enumerate(sel) :
if n>0 :
i.setInput(0, sel, 0)

That's assuming output and input connectors are all index 0

Havent test it in Houdini as I replied from phone. But you got the idea.
User Avatar
Member
2624 posts
Joined: 8月 2006
Offline
Hi Ferry that works ! , it certainly helps me get to grips with python. My next issue to pull apart is defining functions. ! . I figured I should create the nodes , then list them , then join.


Rob
Edited by - 2015年3月21日 22:48:03
Gone fishing
User Avatar
Member
392 posts
Joined: 11月 2008
Offline
Just typo.

childrenOfnode(node) != childrenOfNode(n)
User Avatar
Member
2624 posts
Joined: 8月 2006
Offline
Thanks I go that ! ……. I think I must just turn this into a python thread. Thanks for all the help

Rob
Gone fishing
User Avatar
Member
2624 posts
Joined: 8月 2006
Offline
Hi all,

I can create a list of nodes children() how can I delete a specific node from a list . for example I want to delete the file1 node but there may be 25 nodes in there. I was thinking along the lines of a if statement to look at a list ie

variable = somenode.something(“file1”)
if var = true
blah.destroy()

master = hou.node('/obj')
node = master.createNode('geo', ‘obj_box’)
node.moveToGoodPosition()

for child in node.children():
print child



Rob
Gone fishing
User Avatar
Member
678 posts
Joined: 7月 2005
Offline
# select OBJ node
sel = hou.selectedNodes()

# get children as list instead of standard tuple
childs = list(sel.children())

# remove from list and destroy node by using list comprehension as a filter

User Avatar
Member
2624 posts
Joined: 8月 2006
Offline
Hi,
Thanks for the pointer I will give it a crack

Rob
Gone fishing
User Avatar
Member
2624 posts
Joined: 8月 2006
Offline
python ……..

# create empty geo node
obj = hou.node(“/obj”)
n = obj.createNode(“geo”, “box_obj”)
n.moveToGoodPosition()
p = n.parmTuple(“t”).set((2,0.5,0))
### create box node inside
b = n.createNode(“box”)
b.parmTuple('size').set((1, 1, 1))

sel = n.setSelected(True)

Taking the previous post I figured how I could automatically select an object on creation then delete the file1 sop. I am going to stick my neck out and assume its not best practice to select then delete. I had a crack at deleting the file1 sop with an approach where I did not select the node. All I got was hou.object didn't support inline . Any other workflows I could explore ?

Rob
Gone fishing
User Avatar
Member
678 posts
Joined: 7月 2005
Offline
A little late, so you probably figured this out till now, but take a look at what arguments can be passed into this method:
http://www.sidefx.com/docs/houdini14.0/hom/hou/Node#createNode [sidefx.com]

If you set run_init_scripts = False, than it will create only container without file1.
  • Quick Links