Simple operator instantiation from a shelf button.

   2597   3   1
User Avatar
Member
380 posts
Joined: July 2005
Offline
hi, i have some standard code in a shelf button setup by a site wide shelf file.


<script scriptType=“python”><![CDATA[import drivertoolutils
drivertoolutils.genericTool(kwargs,“fx_Outliner”)]]>
</script>

i just want the driver node to be dropped into the out network,
but instead i get the following error when i hit the shelf button:

Traceback (most recent call last):
File “driver_fx_Outliner”, line 1, in <module>
File “drivertoolutils.py”, line 7, in genericTool
toolutils.genericTool(scriptargs, nodetypename, nodename)
File “toolutils.py”, line 603, in new_func
return function(*args, **kwargs)
File “toolutils.py”, line 673, in genericTool
run_init_scripts = False)
File “/home/prisms/builder-new/Nightly10.0/dev/hfs/houdini/scripts/python/hou.py”, line 3679, in createNode
return _hou.Node_createNode(*args, **kwargs)
OperationFailed: The attempted operation failed.
Invalid node type name


Currently We do the same thing for all operator types
It works for sops, and somewhat for Objects and Pops
(it asks for the user to do some selection) but not
really at all for driver types.

Any idea how to get simple ‘instantiate one in the
appropriate network’-type functionality?

any input would be appreciated, thanks.
User Avatar
Member
7720 posts
Joined: July 2005
Online
sdugaro
i just want the driver node to be dropped into the out network

Why not just do something like this?

hou.node(“/out”).createNode(“fx_Outliner”, “fx_Outliner1”)
User Avatar
Member
380 posts
Joined: July 2005
Offline
ok, ill try that. thanks!
User Avatar
Member
1906 posts
Joined: Nov. 2006
Offline
The problem with calling a tool from the shelf is that it's not being called from a specific pane, and therefor the scripts make a call to toolutils.activePane() to try and figure out where the new node should be placed. In this case, if you are in a default scene at the Object level, you will be attempting to create your ROP at /obj, where that node type doesn't exist.

If you look in the MainMenuCommon file you see that the menu items use roptoolutils.createRenderNode() to generate new ROPs. This module basically just calls the code Edward posted. Not sure what exactly drivertoolutils is used for.

As for some single function that can automatically and smartly create nodes in their proper contexts given by their node type names would be difficult given that multiple node types in different contexts can have the same name. You could write a function that would search all the type categories for their node types and find the first match but you run the risk of getting the wrong one.
Graham Thompson, Technical Artist @ Rockstar Games
  • Quick Links