USD python asset resolver

Looking for Asset Resolver ( ArResolver ) of USD to load a Stage where path is coming from different drive or different platform while loading content in unreal. Relative path is as option but if the stage is contains absolute path then just to be ready for this as well.

I have build the asset resolver with the help LucaScheller (LucaScheller) · GitHub and able to launch the unreal with the custom usd resolver but now I need help to set the context before load.

Here is the link to build resolver

Hey Rohit,

I’m trying to do that as well for linux → windows absolute paths.
So far, I’ve only compiled the FileResolver, thinking I would only need to modify this resolver, am I wrong ?

Do you use the environment variables or the USD “Additionnal Plugin Directories” in the project settings ?

Even though I’m using TF_DEBUG, I don’t see anything in the logs. How do you know if it’s loaded properly ?

EDIT: I’ve added a TF_WARN(“Hello world”) in my FileResolver::_Resolve function and it prints, so I guess it is loaded. I’m using the “Additionnal Plugin Directories” project settings only. I modified _Resolve and now it works. What context are you refering to exactly ?

I assume you’re talking about resolverContext, but I mean what’s the issue exactly.

Hi,
MaD_RDO I was looking set the context before loading the stage so that I can just open the file with that context.

I have set the environment variable to set the context before launch of Unreal for now to test it, currently I am using pythonResolver instead.

I wasn’t paying attention to the absolute path for the root_layer path of UsdStageActor but the context was already then I tried to load the actual file and everything seems to be working

Environment variable:

set REPO_ROOT=C:/path/to//VFX-UsdAssetResolver-main
set UE_PYTHONPATH=%REPO_ROOT%/dist/%AR_RESOLVER_NAME%/lib/python;%PYTHONPATH%
set PXR_PLUGINPATH_NAME=%REPO_ROOT%/dist/%AR_RESOLVER_NAME%/resources;%PXR_PLUGINPATH_NAME%
set LD_LIBRARY_PATH=%REPO_ROOT%/dist/%AR_RESOLVER_NAME%/lib;%LD_LIBRARY_PATH%

set AR_SEARCH_PATHS=%REPO_ROOT%/files/generic/workspace/shots;%REPO_ROOT%/files/generic/workspace/assets
set AR_SEARCH_REGEX_EXPRESSION="(bo)"
set AR_SEARCH_REGEX_FORMAT="Bo"

I am sharing the code for reference

from pxr import Usd , Ar , Sdf , UsdUtils
stage_cache = UsdUtils.StageCache.Get()
stage = stage_cache.GetAllStages()[0]
context_collection = stage.GetPathResolverContext()
pythonResolver_context = context_collection.Get()[0]
print(pythonResolver_context.GetData())

#LogPython: {"searchPaths": ["C:\\path\\to\\VFX-UsdAssetResolver-main\\files\\generic\\workspace\\shots", "C:\\path\\to\\VFX-UsdAssetResolver-main\\files\\generic\\workspace\\assets"], "mappingRegexExpression": "\"(bo)\"", "mappingRegexFormat": "\"Bo\"", "mappingPairs": {}}