Jump to content

[Solved] External python script in HDA modules

Recommended Posts

Posted (edited)


I once saw a tutorial that explained, how to import another python script inside a HDA - but I dont find it anymore.

On the screenshot I try to explain what I mean.

I am not sure anymore if it was import xyz from xyz or something like that.

Could someone give me a hint? :)

Thanks alot,




Edited by sant0s81

Share this post

Link to post
Share on other sites

To import a specific script in Python you need to append the folder where it is to the python path (the path contains all the paths to the different modules it loads). You can do it using the sys module :

import sys


import myscript

And if you want to import just a specific function from your file and not all the file :

import sys


from myscript import myfunction 



  • Like 2

Share this post

Link to post
Share on other sites

If I understand correctly this question: How import into the PythonModule a Custom Script stored in HDA ?

Like your screenshot, to import all functions stored into "import_that_script" inside the PythonModule.

There is an answer in docs: https://www.sidefx.com/docs/houdini/hom/hou/HDAModule.html



If you find that a digital asset has too much Python code to store in one module, it’s possible to create submodules. For example, if you want to create a submodule named bar, put its source code in a new digital asset section (say, "bar_PythonModule"). Then, from the Python Module section, you can write the following:

import toolutils
bar = toolutils.createModuleFromSection("bar", kwargs["type"], "bar_PythonModule")


So in your case in the PythonModule section:

import toolutils
myscript = toolutils.createModuleFromSection("myscript", kwargs["type"], "import_that_script")

Then, you can execute a function as imported module do: myscript.myfunction()

  • Like 1

Share this post

Link to post
Share on other sites


Great, thats actually what I was trying - but than stored the script in a file and used the technique mentioned above.

But yes, thats what I was thinking.

Thx! :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now