# Get all references sublayers recursively of stage

**URL:** <https://forum.aousd.org/t/get-all-references-sublayers-recursively-of-stage/1322>\
**Category:** USD\
**Tags:** python\
**Created:** [March 14, 2024, 4:01pm UTC](https://forum.aousd.org/t/get-all-references-sublayers-recursively-of-stage/1322 "2024-03-14T16:01:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulgolter](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/paulgolter/32/276_2.png) [@paulgolter](https://forum.aousd.org/u/paulgolter)\
**Post date:** [March 14, 2024, 4:01pm UTC](https://forum.aousd.org/t/get-all-references-sublayers-recursively-of-stage/1322/1 "2024-03-14T16:01:09Z")

</div>

Hey all,

just wondering is there an easy way with the Usd python binding to get a list of all references / sublayers, essentially “other” usd files that contribute to a usd stage?

Before I look in to how I can write a crazy recursive algorithm I am wondering if there is something out there already or any utilities that can help here.

Thanks!

---

<div class="post-metadata">

**Author:** ![BigRoyNL](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/bigroynl/32/413_2.png) [@BigRoyNL](https://forum.aousd.org/u/BigRoyNL)\
**Post date:** [March 14, 2024, 4:38pm UTC](https://forum.aousd.org/t/get-all-references-sublayers-recursively-of-stage/1322/2 "2024-03-14T16:38:34Z")

</div>

If you have a composed stage I think you can use `stage.GetUsedLayers()` to get the layers that were involved with the composition. I believe that also returns the layers of references/payloads that actively contributed to the current composition. However it would exclude those that did _not_ contribute to the composition, e.g. those in other variants, etc.

Otherwise you might be able to use [`UsdUtils.ComputeAssetDependencies`](https://openusd.org/dev/api/dependencies_8h.html#a8662e2c916302e2022adb977af8c2d94), for example:

```python
UsdUtils.ComputeAllDependencies(stage.GetRootLayer().identifier)

```

Which I think may include more. Note that asset dependencies may also be textures, etc.

There’s also [`UsdUtils.ExtractExternalReferences`](https://openusd.org/dev/api/dependencies_8h.html#aea333599199c52378631fbb3a409301c) which may be of interest and potentially is more likely what you need.

---

<div class="post-metadata">

**Author:** ![spiff](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/spiff/32/22_2.png) [@spiff](https://forum.aousd.org/u/spiff)\
**Post date:** [March 14, 2024, 5:45pm UTC](https://forum.aousd.org/t/get-all-references-sublayers-recursively-of-stage/1322/3 "2024-03-14T17:45:52Z")

</div>

`ComputeAssetDependencies()` is the most comorehensive option, and gives you the ability to filter out things you don’t want, as it’s going (in the dev branch only, currently - it’s just been largely rewritten and vastly improved).

`ExtractExternalReferences()` is single-layer only, so you’d still need to do the crazy recursion yourself 🙂
