Access variables between two Python SOPs

   384   3   1
User Avatar
Member
25 posts
Joined: Jan. 2015
Offline
Is there a way to make variables in one Python SOP available to the Python script in another Python SOP?
Edited by element33 - June 6, 2022 07:56:20
User Avatar
Member
721 posts
Joined: Feb. 2016
Offline
You can use the hou.session module (where you can store also functions available everywhere in the houdini session)
You can write directly to it in the Python Source Editor (access it from Windows menu)

Or you can write to it from any python location
hou.session.myVar = 1
print(hou.session.myVar)
User Avatar
Member
25 posts
Joined: Jan. 2015
Offline
Great, thanks.
User Avatar
Member
25 posts
Joined: Jan. 2015
Offline
One more question: if I have 2 Python SOPs: 1) the main Python SOP with some script, 2) a secondary Python SOP, not attached to anything, whose purpose is just to store some variables (let's say it contains just "hou.session.myVar = 1"). Do I need to force the cook of the secondary node from the main node to get access to the variable, since the secondary node is not attached to anything, so it has no reason to cook by itself?
  • Quick Links