Jump to content
Sign in to follow this  
Shalinar

Weird Behavior - createOutputNode

Recommended Posts

Shalinar    1

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

Share this post


Link to post
Share on other sites
graham    135

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.

Share this post


Link to post
Share on other sites
Shalinar    1

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")

 

Share this post


Link to post
Share on other sites
Shalinar    1
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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×