Python store input, disconnect input and reconnect input

   1175   2   1
User Avatar
Member
81 posts
Joined: Feb. 2014
Offline
Hi

On object level I am trying to store and disconnect an input, do in the same script some transforms and reconnect the stored input again.
It gives me errors. Is there something I am overlooking?

def test():
    selected = hou.selectedNodes()
    for kees in selected:
        inputs = kees.inputs()
        print (inputs)
        inputs = str("'"+(str(kees.inputs())[30:][:-3])+"'")
        print (inputs)
        kees.setFirstInput(None)
        #do all kind of transformation stuff
        kees.setFirstInput(hou.node(inputs)

Thanks
Michiel
User Avatar
Member
106 posts
Joined: June 2011
Offline
You can get the input node's path directly and use it instead of getting it using string slice.

def test():
    selected = hou.selectedNodes()
    for kees in selected:
        inputs = kees.inputs()
        print (inputs)
        kees.setFirstInput(None)
        #do all kind of transformation stuff
        kees.setFirstInput(hou.node(inputs[0].path()))

-J
Edited by jjayakumar - Nov. 9, 2019 10:35:23
User Avatar
Member
81 posts
Joined: Feb. 2014
Offline
Hi -J, that is surprisingly elegant.. Thanks for the help out, greatly appreciated!
  • Quick Links