Can USD C++ toolkit load a model with external references like this?

Hi USD experts,

I am meeting an issue to need your support. For attached sublayers.usda, it references another two external “TwoBoxes.usda”, “mesh.usda” in “sub” folders. Now, I try to change folder name on the disk - “sub” into “sub_rename” manually. But sublayers.usda content still keeps unchanged and references external files in “sub” folders. Also, I copied external “TwoBoxes.usda”, “mesh.usda” and put them into the folder that sublayers.usda is located in.

Now if I try to open sublayers.usda in usdviewer, it fails to load sublayer in “sub” folder. Using USD C++ toolkit also fails to get children by calling rootPrim.GetChildren().
My question: Is it still possible to load the external files successfully for such usd model using USD C++ toolkit?
C++ APIs calling:
pxr::UsdStageRefPtr stage = pxr::UsdStage::Open(filename)
pxr::UsdPrim pseudoRootPrim = stage->GetPseudoRoot();
auto rootPrims = pseudoRootPrim.GetChildren();

USD files are attached.
usd_files.zip (336.1 KB)

If I understand correctly, you want to rename the “sub” folder on the file system to “sub_rename”, and still have USD be able to find the corresponding files?

However, perhaps we should first clarify what your goal is. With Ar Resolver, you can customize the asset path resolution behavior. For example, you could implement logic so that any path containing the string “xxx” is resolved to “xxx_rename”, but I’m not sure if that’s really what you want.

If you need some examples of Ar Resolvers, you might want to refer to this thread: USD Asset Resolver - Practical Example/Reference Implementations

Thank you! I saw this topic( Baking all external Asset Paths - Community / USD - Alliance for OpenUSD) helps me solve my issue.

1 Like