Get all references sublayers recursively of stage

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.


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, for example:


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

There’s also UsdUtils.ExtractExternalReferences which may be of interest and potentially is more likely what you need.

1 Like

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 :slight_smile: