I can't find how the hom finds the global variables, i have some custom ones made for my scene I would like to access from Python scripts.
Word.
-Andrew
Python Access to aliases and global Varialbes.
5564 5 2- amelnychuk
- Member
- 15 posts
- Joined: Jan. 2010
- Offline
- graham
- Member
- 1908 posts
- Joined: Nov. 2006
- Offline
You can access them a couple ways.
set MYVAR=5
You can use HOM methods to evaluate the variable values:
>>> hou.hscriptExpression(“$MYVAR”)
'5'
>>> hou.expandString(“MYVAR”)
Also, if you define the variables using something like your bashrc file you can use the os module environment stuff.
>>> os.environ
'5'
set MYVAR=5
You can use HOM methods to evaluate the variable values:
>>> hou.hscriptExpression(“$MYVAR”)
'5'
>>> hou.expandString(“MYVAR”)
Also, if you define the variables using something like your bashrc file you can use the os module environment stuff.
>>> os.environ
'5'
Graham Thompson, Technical Artist @ Rockstar Games
- amelnychuk
- Member
- 15 posts
- Joined: Jan. 2010
- Offline
- sdugaro
- Member
- 380 posts
- Joined: July 2005
- Offline
- sdugaro
- Member
- 380 posts
- Joined: July 2005
- Offline
prob also good to mention here that one will throw and expection if the variable isnt set while the other will just return the empty string (hom)
>>> hou.expandString(“$BLAH35”)
''
>>> hou.hscriptExpression(“$BLAH35”)
Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “/net/apps/spinux1/houdini/hfs12.5.427/houdini/python2.6libs/hou.py”, line 34791, in
hscriptExpression
return _hou.hscriptExpression(*args)
OperationFailed: The attempted operation failed.
Undefined variable
>>> hou.expandString(“$BLAH35”)
''
>>> hou.hscriptExpression(“$BLAH35”)
Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “/net/apps/spinux1/houdini/hfs12.5.427/houdini/python2.6libs/hou.py”, line 34791, in
hscriptExpression
return _hou.hscriptExpression(*args)
OperationFailed: The attempted operation failed.
Undefined variable
- graham
- Member
- 1908 posts
- Joined: Nov. 2006
- Offline
-
- Quick Links