How to transfer a variable from one python node to another?

   2448   2   1
User Avatar
Member
5 posts
Joined: Dec. 2017
Offline
Hello, I am writing code using Houdini but my knowledge of Houdini is not that great. I have two python nodes, one that needs to be time dependent and one that is not. I need to use two variables from the time independent python node in the time dependent one. One variable is weights which I think can be done by assigning my weights to the ‘Pw’ attribute of my geometry or as a custom attribute.

The problem with the second is that it is a dictionary that stores a list of objects and their vectors to a specific point and I don't believe a dictionary can be assigned as an attribute. Does anybody know what I can do with this situation?

Cheers
User Avatar
Member
1743 posts
Joined: March 2012
Offline
Would it work to create a string array attribute and a vector (3-float) array attribute, and put the keys (the strings) in one and the corresponding values (the vectors) in the other?
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
5 posts
Joined: Dec. 2017
Offline
I found a simpler solution. I initialised two variables in the python source editor, e.g. myVar = {} and in my python node did
hou.session.myVar = myVariable

Then I can access this in my other python node by:

myVariable = hou.session.myVar
Edited by carmo - Jan. 7, 2018 14:59:58
  • Quick Links