ivan Posted October 13, 2010 Share Posted October 13, 2010 so, it's inmpossible to retrieve hou.parmTuple() values inside a python module?!?!! print hou.pwd() returns /, and as far as I can tell, there is no way to determine what the path to the SOP that an .hm() function came from?!?!! I've tried making a global var and using an onCreated function to access this data: this is in the onCreated module: hou.node(kwargs['node'].path()).hm().set_selfnodepath(kwargs['node'].path()) and this is in the module: selfnodepath = "abc" def set_selfnodepath(newpath): global selfnodepath selfnodepath = newpath which coredumps often..... WHY ON EARTH ISN'T kwargs['node'] VALID IN A HOUDINI MODULE?!?!?!!! Quote Link to comment Share on other sites More sharing options...
graham Posted October 13, 2010 Share Posted October 13, 2010 A PythonModule is just a regular module that has no relation to an instance of the asset. It exists inside the operator definition as a place to store code to run things related to that asset. It's just a module and there is really no difference between it and if you were using a module from a location on disk. So that's why kwargs doesn't actually exist inside the module. If you are going to call functions inside that module then generally you'll want to have the first parameter to the function as an instance of a node, particularly the node type of that asset. If you want node specific data you can user per-node user data dictionary. PythonModule: def printPath(node): print node.path() OnCreated: node = kwargs['node'] node.hm().printPath(node) Quote Link to comment Share on other sites More sharing options...
ivan Posted October 13, 2010 Author Share Posted October 13, 2010 yes, this is similar to what I had. Now imagine this scenario: there is a databasey-type thing that connects to Houdini via python. You want to get data from it and set values in your UI based on the contents of the DB. You have very little control over this DB, and it works in an odd way: you call a function (gimme_data("chumps",hou.node("foo").hm().myfunc)) and it returns data by calling your provided function (hou.node("foo").hm().myfunc(MYdata)). So, now, your module function gets called, but you cannot use the data: def myfunc(mydata): print mydata hou.parmTuple("WTF_is_my_path").set(mydata[0]) Quote Link to comment Share on other sites More sharing options...
ivan Posted October 13, 2010 Author Share Posted October 13, 2010 ok, this is my workaround: since the onCreate module isn't working, I now have a callback button. You click that, and in the button hou.pwd().hm().go(hou.pwd().path()) and in the module def go(inNodePath): global selfnodepath selfnodepath = inNodePath gimme_data("chumps",hou.node(inNodePath).hm().myfunc() def myfunc(mydata): global selfnodepath hou.parmTuple(selfnodepath).set(mydata[0]) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.