catchyid Posted April 12, 2017 Share 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 Quote Link to comment Share on other sites More sharing options...
f1480187 Posted April 12, 2017 Share 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 Quote Link to comment Share on other sites More sharing options...
catchyid Posted April 12, 2017 Author Share Posted April 12, 2017 Thaaaaaaaaaaaaaaaaaaaaaaaaaaaanks Quote Link to comment Share on other sites More sharing options...
davpe Posted February 18, 2021 Share Posted February 18, 2021 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. Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted February 18, 2021 Share Posted February 18, 2021 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") Quote Link to comment Share on other sites More sharing options...
davpe Posted February 18, 2021 Share Posted February 18, 2021 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. Quote Link to comment Share on other sites More sharing options...
anim Posted February 18, 2021 Share Posted February 18, 2021 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 Quote Link to comment Share on other sites More sharing options...
davpe Posted February 19, 2021 Share Posted February 19, 2021 thanks anim, user data thing sounds promissing. will look into that. 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.