[SOLVED] Python: Global Variables

   7729   3   1
User Avatar
Member
267 posts
Joined:
Offline
Is there a way to create a variable in Houdini and have access to it from anywhere?

Sort of like the Houdini Global Variables?

I would like to create and store a datetime object data from a Pre-Render Script, then do a delta for a Post-Render Script (to compute load time).. yet it errors out because I'm unable to access the datetime object that I created in the Pre-Render stage.

I'm hoping to not create external text file logs as this is just a straight forward timestamp check.
Edited by galagast - May 6, 2017 12:53:12
User Avatar
Member
267 posts
Joined:
Offline
Just minutes after posting, I may have found a good lead..
Looking into node UserData now
http://www.sidefx.com/docs/houdini/hom/hou/Node#UserData [sidefx.com]
Hopefully I'm on the right track >_<

EDIT: yup, got it working using this )
Edited by galagast - May 6, 2017 12:52:54
User Avatar
Member
2162 posts
Joined: Sept. 2015
Offline
For Python Globals…I like to use the Python Source Editor ( under Windows tab ).

I put my globals variables and/or functions there and simply use hou.session to access/set them, e.g.

In Python Source Editor:
My_Global = 0

def Add_To_Global(AddNew):
return My_Global + AddNew

Then I can do something like this in a python paramter script:
hou.session.My_Global = 5
return hou.session.Add_To_Global(3)
User Avatar
Member
267 posts
Joined:
Offline
Thank you for the tip babaj!
That sounds more Global to me, I will use it next time for sure
  • Quick Links