Jump to content

Global variable using python


defc0n1

Recommended Posts

7 minutes ago, lukeiamyourfather said:

Never tried it but it should work. After creating the variable call global like this.


foo = 25
global foo

 

Hi Luke

Doesn't seem to work - SyntaxWarning: name 'foo' is assigned to before global declaration :(

Link to comment
Share on other sites

Depends on what are you trying to achieve.

1. If you wanted to store something per node , with the possibility to keep the info in the hip file.

2. hou.session module, where you can store and share Python objects within the current session of Houdini.

3. HOM shortcuts to modify the current environment variables: hou.getenv(), hou.putenv() and hou.unsetenv()
It will be available for use in parameters as $MYVARNAME until you close Houdini. It will not appear in the Aliases and Variables window, however.

4. If you really want to modify HDA definition globally, you can add a Section and save definition after that.
It will be available in the Extra Files tab of the Operator Type Properties window.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

21 hours ago, f1480187 said:

Depends on what are you trying to achieve.

1. If you wanted to store something per node , with the possibility to keep the info in the hip file.

2. hou.session module, where you can store and share Python objects within the current session of Houdini.

3. HOM shortcuts to modify the current environment variables: hou.getenv(), hou.putenv() and hou.unsetenv()
It will be available for use in parameters as $MYVARNAME until you close Houdini. It will not appear in the Aliases and Variables window, however.

4. If you really want to modify HDA definition globally, you can add a Section and save definition after that.
It will be available in the Extra Files tab of the Operator Type Properties window.

Thanks for the help guys. I managed to do what I wanted by just passing around some detail attributes. Seemed much simpler!

Link to comment
Share on other sites

  • 5 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...