Custom global variable set by Python function?

   4410   2   0
User Avatar
Member
88 posts
Joined: July 2005
Offline
I have a python function hipver() defined in my pythonrc. It returns the version part of the current hip file as a string. I'm trying to use this as part of a string parameter (Output picture parm on the Mantra ROP - I miss my pipeline from work ). It evaluates correctly in the houdini python shell but doesn't work in a string param on a node. While Googling around I found out about needing to key the string param, that I can't use backticks to evaluate a python function, etc.

I want it to be scene independent and I don't want to have to set the node to use Python Expressions, so I think the best way would be for an HScript global variable (e.g. $HIPVER) to contain the output of the python function. Is this possible and can someone help me set that up or point me in the right direction?

Thanks in advance!
/ken_jones/$: _
User Avatar
Member
8177 posts
Joined: Sept. 2011
Offline
hou.hscript("set -g HIPVER={}".format(hipver()))
User Avatar
Member
88 posts
Joined: July 2005
Offline
Nice! I put that in my 123.py/456.py and it works great

Thanks jsmack!
/ken_jones/$: _
  • Quick Links