This PR exposes Python bindings for ArAsset of the Asset Resolver module, ultimately enabling operations such as ArResolver.OpenAsset(resolvedPath) to allow reading ArAsset buffers from Python (which was previously only available from C++).
The proposed changes enable features such as querying contents of assets referenced within USD Stages by way of the path resolution behaviors already implemented within Asset Resolvers.
Python Sample
This PR enables the following type of workflow from Python (see unit tests included in the PR for practical examples).
Assumptions:
The existence of a Stage containing a "/TestPrim" Prim with a "custom:jsonFilePath" Attribute referencing a JSON asset.
A JSON asset located on disk with the following content:
The following Python snippet illustrates using the OpenAsset(resolvedPath: Ar.ResolvedPath), which was previously not exposed:
# [...]
# Retrieve the content of the ArAsset referenced by the Attribute on the Stage:
json_asset = Ar.GetResolver().OpenAsset(resolvedPath=resolved_json_asset_path)
print(f'JSON asset size: {json_asset.GetSize()}')
print(f'JSON asset data: {json_asset.Read()}')
Description of Change(s)
This PR exposes Python bindings for
ArAsset
of the Asset Resolver module, ultimately enabling operations such asArResolver.OpenAsset(resolvedPath)
to allow readingArAsset
buffers from Python (which was previously only available from C++).The proposed changes enable features such as querying contents of assets referenced within USD Stages by way of the path resolution behaviors already implemented within Asset Resolvers.
Python Sample
This PR enables the following type of workflow from Python (see unit tests included in the PR for practical examples).
Assumptions:
"/TestPrim"
Prim with a"custom:jsonFilePath"
Attribute referencing a JSON asset.The following Python snippet illustrates using the
OpenAsset(resolvedPath: Ar.ResolvedPath)
, which was previously not exposed:Which produces the following output: