# Querying tk-houdini context with Python

**URL:** <https://community.shotgridsoftware.com/t/querying-tk-houdini-context-with-python/11252>\
**Category:** Pipeline Integrations\
**Tags:** api, houdini\
**Created:** [January 12, 2021, 4:55pm UTC](https://community.shotgridsoftware.com/t/querying-tk-houdini-context-with-python/11252 "2021-01-12T16:55:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Schneider](https://avatars.discourse-cdn.com/v4/letter/d/7ea924/32.png) [@David\_Schneider](https://community.shotgridsoftware.com/u/David_Schneider)\
**Post date:** [January 12, 2021, 4:55pm UTC](https://community.shotgridsoftware.com/t/querying-tk-houdini-context-with-python/11252/1 "2021-01-12T16:55:18Z")

</div>

Hi there

Is there a way to query the current Shotgun context using python inside Houdini? I’d like to set parameter values according to the current shot/asset and have those values update if the scene is re-saved to a different context.

Regards  
David

---

<div class="post-metadata">

**Author:** ![philip.scadding](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/philip.scadding/32/30_2.png) [@philip.scadding](https://community.shotgridsoftware.com/u/philip.scadding)\
**Post date:** [January 12, 2021, 5:07pm UTC](https://community.shotgridsoftware.com/t/querying-tk-houdini-context-with-python/11252/2 "2021-01-12T17:07:46Z")

</div>

Hi @David_Schneider  
To get the current context from a python script running inside Houdini, but not from a Toolkit app you would do something like:

```python
import sgtk

# get the current Shotgun engine instance
engine = sgtk.platform.current_engine()

# get the current engine context.
ctx = engine.context

```

I’ve not tested that directly in Houdini, but I believe it should work.

> **[Apps, Engines and Frameworks — tk-core v0.19.18 documentation](https://developer.shotgunsoftware.com/tk-core/platform.html?highlight=current_engine#sgtk.platform.current_engine)**

> **[Apps, Engines and Frameworks — tk-core v0.19.18 documentation](https://developer.shotgunsoftware.com/tk-core/platform.html?highlight=current_engine#sgtk.platform.Engine.context)**

---

<div class="post-metadata">

**Author:** ![David\_Schneider](https://avatars.discourse-cdn.com/v4/letter/d/7ea924/32.png) [@David\_Schneider](https://community.shotgridsoftware.com/u/David_Schneider)\
**Post date:** [January 12, 2021, 5:09pm UTC](https://community.shotgridsoftware.com/t/querying-tk-houdini-context-with-python/11252/3 "2021-01-12T17:09:59Z")

</div>

Works great! Thanks Philip.
