# Running code from framework in houdini HDA

**URL:** <https://community.shotgridsoftware.com/t/running-code-from-framework-in-houdini-hda/16743>\
**Category:** Pipeline Integrations\
**Tags:** fptr-tk\
**Created:** [February 3, 2023, 12:38pm UTC](https://community.shotgridsoftware.com/t/running-code-from-framework-in-houdini-hda/16743 "2023-02-03T12:38:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kemer3D](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kemer3D](https://community.shotgridsoftware.com/u/Kemer3D)\
**Post date:** [February 3, 2023, 12:38pm UTC](https://community.shotgridsoftware.com/t/running-code-from-framework-in-houdini-hda/16743/1 "2023-02-03T12:38:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kemer3D](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kemer3D](https://community.shotgridsoftware.com/u/Kemer3D)\
**Post date:** [February 3, 2023, 4:16pm UTC](https://community.shotgridsoftware.com/t/running-code-from-framework-in-houdini-hda/16743/2 "2023-02-03T16:16:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Ricardo\_Musch](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ricardo_musch/32/405_2.png) [@Ricardo\_Musch](https://community.shotgridsoftware.com/u/Ricardo_Musch)\
**Post date:** [February 3, 2023, 4:54pm UTC](https://community.shotgridsoftware.com/t/running-code-from-framework-in-houdini-hda/16743/3 "2023-02-03T16:54:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kemer3D](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kemer3D](https://community.shotgridsoftware.com/u/Kemer3D)\
**Post date:** [February 6, 2023, 12:34pm UTC](https://community.shotgridsoftware.com/t/running-code-from-framework-in-houdini-hda/16743/4 "2023-02-06T12:34:30Z")

</div>

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 ^^
