# Read and process Action Graph from USD file

**URL:** <https://forums.developer.nvidia.com/t/read-and-process-action-graph-from-usd-file/268291>\
**Category:** General Discussion\
**Tags:** omniverse\_extension\
**Created:** [October 3, 2023, 8:13am UTC](https://forums.developer.nvidia.com/t/read-and-process-action-graph-from-usd-file/268291 "2023-10-03T08:13:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhursan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@dhursan](https://forums.developer.nvidia.com/u/dhursan)\
**Post date:** [October 3, 2023, 8:13am UTC](https://forums.developer.nvidia.com/t/read-and-process-action-graph-from-usd-file/268291/1 "2023-10-03T08:13:02Z")

</div>

Hi,

I am trying to write an extension which has to open an USD file, find an Action Graph in it and execute the graph.  
I could read the .usda file this way:

```
stage: Usd.Stage = Usd.Stage.Open(filename)

```

‘fileName’ comes from the extension.toml as a property.

But when I try to get the Action Graph in it like this:

```
(graph, _, _, _) = og.Controller.edit("/World/ag1")

```

I get this error:  
2023-10-03 08:05:01 [2,240,102ms] [Error] [omni.ui.python] OmniGraphError: Could not find orchestration graph for stage GraphPipelineStage.GRAPH\_PIPELINE\_STAGE\_SIMULATION

So it seems for me somehow the stage should be bundled to OmniGraph or application context but I don’t know how to do it from python code.  
I tried to get the given graph on an other way too (e.g.: path = Sdf.Path(“/World/ag1”) …), I have found some examples but none of them works, obviously OmniGraph can’t see the stage I have loaded from .usda file.

How should I make Omnigraph connected to the stage I read from an .usda file, to be able to use the graph for further actions?

---

<div class="post-metadata">

**Author:** ![kit-nvidia-Jen](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kit-nvidia-jen/32/382649_2.png) [@kit-nvidia-Jen](https://forums.developer.nvidia.com/u/kit-nvidia-Jen)\
**Post date:** [December 15, 2023, 12:12am UTC](https://forums.developer.nvidia.com/t/read-and-process-action-graph-from-usd-file/268291/2 "2023-12-15T00:12:44Z")

</div>

> [@dhursan](#):
>
> `(graph, _, _, _) = og.Controller.edit("/World/ag1")`

Try using something like the code below. It could be the stage has not loaded so it cannot grab the graph:

```auto
import asyncio
import carb
import omni.usd
import omni.graph.core as og

path_to_usd_file = 'path'
graph_id = '/World/ActionGraph'

async def open_stage():
	result, error = await omni.usd.get_context().open_stage_async(path_to_usd_file, load_set=omni.usd.UsdContextInitialLoadSet.LOAD_NONE)
	stage = omni.usd.get_context().get_stage()
	controller = og.Controller()
	graph = controller.graph(graph_id)
	if graph:
		carb.log_info("graph exists")
run_loop = asyncio.get_event_loop()
run_loop.create_task(open_stage())

```
