global function from an otl

   1690   2   1
User Avatar
Member
897 posts
Joined: July 2018
Offline
I'm defining a function at startup through the ‘456.py’ file. I can use this on parameters and through the python shell but not in the otl modules. Any way to solve this?

Thanks!
B.Henriksson, DICE
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
HDA Modules are their own modules and don't share anything with the main Houdini Python namespace, so that's why you can't see anything there. I would suggest defining your function in an external module that you can then import into 456.py and into your Python module.

That being said, you can put this code in your asset and it will work:
import __main__
# Where foo() is the function defined in 456.py
__main__.foo()
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
897 posts
Joined: July 2018
Offline
Thanks for clearing it up.
B.Henriksson, DICE
  • Quick Links