Jump to content

Weird Behavior - createOutputNode


Shalinar

Recommended Posts

I'm developing a setup using a Python SOP and came across some behavior that I cannot account for.

In my example scene, you'll see that I just have a cube appended with a Python SOP. Enable the Python SOP to see what happens. Inside the Python SOP I'm just getting the parent node (the cube), then trying two different things: 1) append a transform node to the Python SOP, and 2) append a transform node to the cube. The first succeeds, the second fails due to "invalid node type name", and it spawns multiple transform nodes.

Here's the code:

node = hou.pwd()
parent = node.parent()

# This works just fine:
node.createOutputNode("xform")

# This fails due to "Invalid Node Type":
parent.createOutputNode("xform")

So the first issue is why does createOutputNode from a parent node fail? The error raised is "Invalid node type name", but that doesn't make sense because the same node type name is valid when using createOutputNode from the current node.

The second issue is why do multiple transform nodes get spawned from a single createOutputNode?
EDIT: Only a single transform node spawns when the parent.createOutputNode line is removed, so I believe the second issue is due to the Python SOP re-evaluating the failing code multiple times, each time spawning another successful transform node from the Python SOP.

createOutputNode_example.hip

Edited by Shalinar
Link to comment
Share on other sites

The issue is that the parent node is in fact /obj/example.  In the case of Houdini the parent node is the node that contains an operator, not an input node. Since the parent is an Object it fails because there is no xform node at the object level.

As you mentioned the multiple nodes in the SOP level are a result of the node cooking multiple times, most likely when MMB on it for errors, etc.

Link to comment
Share on other sites

Ah my mistake, "parent" refers to the obj-level container, not the input node. Printing "parent" in my case was misleading because the parent name was the same as the input node's name. Code fixed to:

input = node.inputs()[0]

input.createOutputNode("xform")

 

Link to comment
Share on other sites

Just now, graham said:

The issue is that the parent node is in fact /obj/example.  In the case of Houdini the parent node is the node that contains an operator, not an input node. Since the parent is an Object it fails because there is no xform node at the object level.

As you mentioned the multiple nodes in the SOP level are a result of the node cooking multiple times, most likely when MMB on it for errors, etc.

Thanks Graham, figured out my mistake right as you posted haha :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...