LucaScheller / VFX-UsdAssetResolver

Usd Asset Resolver Reference Implementations
https://lucascheller.github.io/VFX-UsdAssetResolver/
Apache License 2.0
107 stars 22 forks source link

loading FileResolver with pxr #3

Open Viewgob opened 1 year ago

Viewgob commented 1 year ago

Hello! This isn't really an issue with the plug-in but more of a question about best practices when loading it. Is there a recommended way of importing the FileResolver python module so that it's available any time usd is loaded. For example, I have the FileResolver loaded through the PXR_PLUGINPATH_NAME in usdview, but if I print out the contexts, I get an error because a python representation hasn't been created yet for the FileResolverContext:

st.GetPathResolverContext() Traceback (most recent call last): File "", line 1, in TypeError: No to_python (by-value) converter found for C++ type: FileResolverContext

after running:

from usdAssetResolver import FileResolver

it works fine: st.GetPathResolverContext() Ar.ResolverContext(FileResolver.ResolverContext('/assetResolverTest/test.usda'))

Do I need to go to each dcc (houdini/maya/usdview/etc) and add that import statement to it initialization or is there a better way?

Thank you!

LucaScheller commented 1 year ago

Hey, thanks for checking out the repo!

Good question! I'm actually not too familiar with how C++ Python bindings work under the hood, so I can't give you an answer as to if there is a way to auto import it.

I'd recommend asking the same question in the USD forum, maybe someone there can give more insights how USD loads the plugins (or if this is just a general Python binding issue or if maybe some setup code is just missing).

In our production code, we always just import the class somewhere ourselves (in startup scripts or the module that handles resolver related stuff).

-Luca

EDIT: Closing issue for now, please re-open if necessary :)

LucaScheller commented 1 year ago

Hey, I'm actually running into this issue again too currently with the "CachedResolver" implementation. I'm doing the following: cachedResolver.so invokes PythonExpose.py with the active CachedResolverContext, but since the Python representation hasn't been loaded yet it errors, unless it was imported before (as you mentioned above).

Workarounds for now are:

Re-opening this ticket to re-investigate this some point in the future

Viewgob commented 1 year ago

Thank you for your continued support of the plugin!