Changes to parameters in Python/Houdini functions?

   3482   4   1
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
I was following a tutorial on using python in Houdini and the one example shows how to make a shelf tool that lets you drop a box node in the Network Editor.

But I get an error message once I click in the Network editor to lay it down.

Here's the code from the tutorial:

p = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
position = p.selectPosition()
new_node = p.pwd().createNode(“box”)
new_node.setPosition(position)

Here's the error message I get:

Traceback (most recent call last):
File “create_box_node”, line 3, in <module>
File “CPROGRA~1/SIDEEF~1/HOUDIN~1.16/houdini/python2.7libs\hou.py”, line 5279, in createNode
return _hou.Node_createNode(*args, **kwargs)
OperationFailed: The attempted operation failed.
Invalid node type name

From this I gather the “box” in parenthesis is creating the problem and something has changed since the tutorial has been made in how the parameter is passed/referenced for this function?

Any comments are appreciated - Thanks
User Avatar
Member
8599 posts
Joined: July 2007
Offline
it depends on the context your network editor in in as “box” type doesn't exist in all contexts
so you probably want to be in SOP (Geometry) context
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
In this case the network editor is in the right context…because it shows the outline of the node that I am about to place down…also there are already other box and sphere node objects in the Network Editor that this attempt is being made on.

i.e. I can drop down a box node as per the usual way with the TAB menu.
User Avatar
Member
8599 posts
Joined: July 2007
Offline
BabaJ
In this case the network editor is in the right context…because it shows the outline of the node that I am about to place down…also there are already other box and sphere node objects in the Network Editor that this attempt is being made on.

i.e. I can drop down a box node as per the usual way with the TAB menu.

you can drop Box node in Object context, but it's just an alias for “geo” type with box geometry inside, so hou.createNode(“box”) will not work there
try your script in SOP context where it should work
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Ok tamte….now I see what your saying.

Yes…made that change and it works. Thanks.
  • Quick Links