Python get 'Display Flagged' child node

   1830   2   1
User Avatar
Member
70 posts
Joined: 3月 2016
Offline
Hi,

I wanted to make my own shelf tool which can create a node inside all selected nodes, but then also connect it to the ‘display flagged’ node.

I was able to create a node inside all selected nodes, but not to make them connected.

import hou

nodes = hou.selectedNodes()

for n in nodes:  
    clean = n.node(".").createNode("clean")

    print(clean.path())

In the for loop I already tried some variations of:
n.children()
or
chld = n.hou(".")...?


Also I tried using the:

soptoolutils.genericTool(kwargs, 'clean')
but that way only works on one single node, it does straightaway connect to the display flagged node though.

Anyone having a solution?

Thanks,
Chris
Edited by Klonkel - 2019年10月16日 11:05:48
https://www.youtube.com/@Klonkel
User Avatar
スタッフ
3456 posts
Joined: 7月 2005
Offline
import hou
nodes = hou.selectedNodes()

for n in nodes:  
    clean = n.node(".").createNode("clean")
    print(clean.path())

    display = n.displayNode() # finds the node in this nework that has the Display Flag ON

    clean.setFirstInput(display) # wires the first input of clean to the output of display

check out the Cookbook for lots of tips like this
https://www.sidefx.com/docs/houdini17.5/hom/cb/index.html [www.sidefx.com]
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
70 posts
Joined: 3月 2016
Offline
Thank you very much Michael that worked perfect for me!

Chris
https://www.youtube.com/@Klonkel
  • Quick Links