How to load USD from memory?

Hello everyone, I would like to ask how to load USD from memory. There is a similar interface “CreateInMemory” in the API.

You can just pass the in memory layer’s identifier to the open commands.

For Usd.Stage.Open you can pass it the in-memory root layer Sdf.Layer directly. I believe you can also pass it the root layer’s anonymous identifier layer.identifier as the filepath.

For Sdf.Layer.FindOrOpen you can pass it the anonymous identifier - which can be useful if you want a Python Sdf.Layer instance for an anonymous layer created by e.g. another process, library or the C++ API.

This is for example a way that you can manipulate in-memory Maya USD layers yourself. Even though they to provide some ease of access wrappers like mayaUsd.ufe.getStage(proxy) as well.

1 Like