Running code from framework in houdini HDA

Hi all!

I have few python classes that I wanna use in diffrent places (inside hooks, but also in houdini HDA)
I was trying to set up framework, and then import module inside this framework in my HDA python script, but I’m deffinitelly doing something wrong.
So can someone do a little summary of how to use modules from framework inside standalone scirpt/HDA? Ofc I run Houdini through shotgrid desktop app,

Right now I’m trying to get acces to it through sgtk.platform.import_framework() function, and I’m getting this error:

Traceback (most recent call last):
File “C:\Users\p.wiktorek\AppData\Roaming\Shotgun\juicewro\p7596c8010.basic.desktop\cfg\install\core\python\tank\platform\util.py”, line 47, in _get_current_bundle
calling_name_str = caller.f_globals[“name”]
KeyError: ‘name

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “p.wiktorek::Sop/Asset_Loader::1.0, PythonModule”, line 13, in
File “C:\Users\p.wiktorek\AppData\Roaming\Shotgun\juicewro\p7596c8010.basic.desktop\cfg\install\core\python\tank\platform\util.py”, line 234, in import_framework
current_bundle = _get_current_bundle()
File “C:\Users\p.wiktorek\AppData\Roaming\Shotgun\juicewro\p7596c8010.basic.desktop\cfg\install\core\python\tank\platform\util.py”, line 56, in _get_current_bundle
raise TankCurrentModuleNotFoundError(
tank.platform.errors.TankCurrentModuleNotFoundError: import_framework could not determine the calling module layout! You can only use this method on items imported using the import_module() method!

Any help would be appreciated! Thanks

I tried it with a build in framework (tk-framework-qtwidgets)
What I tried to do:

In tk-houdini directory inside info.yml I added this line:
frameworks:
- {“name”: “tk-framework-qtwidgets”, “version”: “v2.10.1”, “minimum_version”: “v2.10.1”}

This code is inside env/included/settings/frameworks.yml:

tk-framework-qtwidgets_v2.x.x:
location:
version: v2.10.1
type: app_store
name: tk-framework-qtwidgets

And finally inside my HDA I have a snippet:
import sgtk
overlay_widget = sgtk.platform.import_framework(
“tk-framework-qtwidgets”, “overlay_widget”
)

And I’m still getting the same error I mentioned above
Where I’m making mistake?

Maybe you can try getting to the engine by using sgtk.platform.current_engine instead of current_bundle.

To anybody that might have simmilar problem, I found a solution:

I was importing my framework incorrectly. What I should have done (besides reading a documentation more carefully xD) is:

engine = sgtk.platform.current_engine()
houdini_framework = engine.frameworks[‘tk-framework-houdini_camera’]
houdini_module = houdini_framework.import_module(‘houdini_module’)

And now I have access to my module inside my HDA ^^

3 Likes