catchyid 31 Posted April 12, 2017 Hi, When I create a digital asset, I go to Scripts->OnCreated() method and write some python script to change some parameters in the newly created digital asset, HOWEVER, I don't know the name of the asset, hence I don't know the path to any node inside the digital asset? When I type hou.pwd(), I get "obj"... Thanks, onCreated.hip Share this post Link to post Share on other sites
f1480187 758 Posted April 12, 2017 (edited) There is Node and NodeType objects in kwargs dictionary available: # Available kwargs contents: print(kwargs) # Node's name like 'test12': kwargs['node'].name() # Set parameter: kwargs['node'].parm('foo').set('123') # Set parameter on node inside subnet: kwargs['node'].node('inside1').parm('foo').set('123') Edited April 12, 2017 by f1480187 1 Share this post Link to post Share on other sites
catchyid 31 Posted April 12, 2017 Thaaaaaaaaaaaaaaaaaaaaaaaaaaaanks Share this post Link to post Share on other sites
davpe 183 Posted February 18 hi guys, I'd need to get one step further with this and read the variables produced in OnCreated script by different scripts in the same HDA (Python Module). Spent a day reading through Houdini docs but can't figure out how to do that. help appreciated. D. Share this post Link to post Share on other sites
Stalkerx777 156 Posted February 18 4 hours ago, davpe said: hi guys, I'd need to get one step further with this and read the variables produced in OnCreated script by different scripts in the same HDA (Python Module). Spent a day reading through Houdini docs but can't figure out how to do that. help appreciated. D. Depending on what you mean by "variables". They can be 1. Environment variables (os.environ), 2. Hip variables (stored in hip): hou.hscript("set -g VAR={}".format(value)) 3. Session variables: hou.session.VAR = "FOO" 4. You can store data on the node: hou.Node.setUserData("VAR", "FOO") and read it back with hou.Node.userData("VAR") Share this post Link to post Share on other sites
davpe 183 Posted February 18 no sorry, I meant like this, for instance: 1. in OnCreate: path = hou.pwd().path() 2. in PythonModule i want to access this path string. this is a trivial example, I'm just looking for a general way to exchange data between HDA scripts triggered on different events - if it makes sense. Share this post Link to post Share on other sites
anim 1,192 Posted February 18 I'm not sure you can pass python variables like that as those are separate scopes and I'd avoid using global variables however you can store data on the instance itself and then retrieve at any time using setUserData() or setCachedUserData() if you don't need them to persist after you close the session https://www.sidefx.com/docs/houdini/hom/hou/Node.html#setUserData Share this post Link to post Share on other sites
davpe 183 Posted February 19 thanks anim, user data thing sounds promissing. will look into that. Share this post Link to post Share on other sites