python external file in hda

   6477   5   1
User Avatar
Member
33 posts
Joined: Sept. 2009
Offline
Hello I searched but could not find answers.
I'm making a custom rop and on ButtonPress I want to call a method in my python script. This works if the code is in the hda scripts section but I don't want write all code in there.

Is there a way to get Houdini to see my code that resides on disk this way I can use my fav txt editor?

Thank you
User Avatar
Member
33 posts
Joined: Sept. 2009
Offline
Nevermind I found this post on the mailing list
http://www.sidefx.com/index.php?option=com_mailarchive&Itemid=212&view=WEB&msgid=AANLkTikKBSP6vR=E=7i=KLQfm=-E6c84ogRGDjzzdFXi@mail.gmail.com&perpage=20&revdate=off [sidefx.com]

I was pulling my hair out coding in the scripts section of the hda
User Avatar
Member
897 posts
Joined: July 2018
Offline
Link is broken. Anyone got an idea on what it said?
B.Henriksson, DICE
User Avatar
Member
7770 posts
Joined: Sept. 2011
Offline
Who knows, but importing modules that reside outside of the HDA sections is trivial. Ensure the library path is in your python path, and import away. If you are a home user, generally you would amend the path from your houdini.env file. Studio environments will have their own unique ways of dealing with path management.

If you don't want to change your python path, modules in scripts/python anywhere in your houdini path are included in your python path automatically, e.g. $HOME/houdini16.0/scripts/python/my_module.py

http://www.sidefx.com/docs/houdini/hom/locations [www.sidefx.com]
User Avatar
Member
897 posts
Joined: July 2018
Offline
That's what we're doing atm but for a special case we would like the hda to not have any external dependencies and include the python libraries inside it. But if this doesn't work we have to do as you describe.
Edited by kahuna031 - Aug. 9, 2017 05:28:11
B.Henriksson, DICE
User Avatar
Member
7770 posts
Joined: Sept. 2011
Offline
kahuna031
That's what we're doing atm but for a special case we would like the hda to not have any external dependencies and include the python libraries inside it. But if this doesn't work we have to do as you describe.

The OP was asking for the opposite of that – reference external python files. If you want to bundle your python in your asset, then embed it using the scripts tab of the hda def editor. You can have multiple scripts, and reference them in the python module by using toolutils.createModuleFromSection().
  • Quick Links