How can I get the Asset path from a Prim

Hello,
I want to retrieve in the code the information about the asset path (I need the nucleus url) from a primitive (it’s loaded from a prepend) but I’m confused on how can I do it. It doesn’t appear as an atribute and I have been taking a look at the ArResolver class but I’m not sure neither how to use it or if that’s the correct way. If anyone has a hint it would be highly appreciated.
Thank you!


I am not sure if this is the correct way, but the following code snippet worked for me:

from pxr import Usd, UsdGeom
import omni.usd

# Configure variables
asset_path = "<your_asset_path>"
prim_path = "/World/test_object"

# Get stage
stage = omni.usd.get_context().get_stage()

# Add payload
prim = stage.DefinePrim(prim_path, "Xform")
payloads = prim.GetPayloads()
res = payloads.AddPayload(asset_path, prim_path)

# Get payload asset path
prim = stage.GetPrimAtPath(prim_path)
stack = prim.GetPrimStack()
print(stack[0].payloadList.prependedItems[0].assetPath)

Thank you so much @ml-thousandlakes ! This is what I needed
Seems like I wasn’t even close to that function, I will take a deeper look into the usd docs haha

@inessorzano looks like you can also use Usd.PrimCompositionQuery. I feel this might be a better/faster way, but I couldn’t get the payloads show on the results. You could also take a look at this one, if you have more time.

Great, I am glad you have your answer.