Houdini subnet None input operators

   1502   6   2
User Avatar
Member
13 posts
Joined: 12月 2016
Offline
Hey guys,

I am trying to mimic the inputs of the merge node. In the merge node if you have three inputs and disconnect the middle input then you can see in the “Input Operators” that the you will only see three inputs.

If I create a simple subnet with just nulls in the inside and connect three inputs and disconnect the middle input, you will see a blank “None” input in the “Input Operators”.

How can I recreate this merge node functionality?

Merge node with the middle node disconnected:


Simple subnet with the middle node disconnected:


Thanks!

Attachments:
mergeNode.png (54.6 KB)
basicSubnetNode.png (48.8 KB)

User Avatar
Member
209 posts
Joined: 3月 2018
Offline
I used OnInputChanged event handler to disconnect and reconnect all inputs whenever input contains a None item but Houdini crash constantly in the most recent production build 18.0.416!
So I used another method to this issue:
Place a Python SOP inside your digital asset with this code:
currentNode = hou.node("..")
inputs = currentNode.inputs()
if None in inputs:
    index = 0
    for input in inputs:
        try:
            currentNode.setInput(index, None)
        except:
            pass
        index += 1
index = 0
for input in inputs:
    if input != None:
        currentNode.setInput(index, input)
        index += 1
It should give you the result.
Edited by N-G - 2020年3月27日 15:47:29
User Avatar
Member
77 posts
Joined: 2月 2017
Offline
N-G
I used onInputChanged signal to disconnect and reconnect all inputs whenever input contains a None item but Houdini crash constantly in the most recent production build 18.0.416!
my houdini 18.0.417 also crash…
My Youtube Channel [www.youtube.com]
User Avatar
Member
209 posts
Joined: 3月 2018
Offline
zengchen
my houdini 18.0.417 also crash…
Therefore you may want to submit a bug for this and stick with the second approach until they fix it.
User Avatar
Member
13 posts
Joined: 12月 2016
Offline
Thanks for the advice!

Ah. This crashes as it calls an infinite recursion. The OnInputChanged script gets called again as the the input is set during the loop. I get why it does that but I'm curious if there is a way to prevent the OnInputChanged from calling itself or any event calling another event.
Edited by harshmallow - 2020年3月27日 10:32:33
User Avatar
Member
77 posts
Joined: 2月 2017
Offline
dacrow
Ah. This crashes as it calls an infinite recursion.

Yes, I suddenly realized it
Edited by zengchen - 2020年3月27日 10:42:54
My Youtube Channel [www.youtube.com]
User Avatar
Member
209 posts
Joined: 3月 2018
Offline
dacrow
Thanks for the advice!

Ah. This crashes as it calls an infinite recursion. The OnInputChanged script gets called again as the the input is set during the loop. I get why it does that but I'm curious if there is a way to prevent the OnInputChanged from calling itself or any event calling another event.

Try this in OnInputChanged event handler:
currentNode = kwargs["node"]
inputs = currentNode.inputs()
index = 0
if len(inputs) != 0 and None in inputs:
    noneIndex = inputs.index(None)
    for input in inputs[noneIndex+1:]:
        if input != None:
            currentNode.setInput(inputs.index(input), None)
            currentNode.setInput(noneIndex, input)
            noneIndex += 1
it is not crash this time since it doesn't call for infinite times!
Edited by N-G - 2020年3月27日 15:49:57
  • Quick Links