Find absolute path of a usd file / texture image used in a scene

Hello,
I am trying to find the absolute path of a texture image used inside my built scene by code. What i currently have in a relative path from the base usd file.
Here are a couple of images:


looking at the source of the texture, it is a relative path. When I press locate file icon next to the source, my content file navigates me to the exact location of the image. I would like to grab the absolute path of these texture images without having to deal with relative paths from different usd files used inside the other by code.

thank you for your help
best
Anthony

Hi @toninsemaan. That attribute is an Sdf.AssetPath. I think Sdf.AssetPath.resolvedPath should give you the absolute path. Hover over the attribute label to get the attribute name to use in the code. Here’s the code:

from pxr import Usd
import omni.usd

stage = omni.usd.get_context().get_stage()
prim_path = "/World/Looks/OmniPBR/Shader"
prim = stage.GetPrimAtPath(prim_path)
texture = prim.GetAttribute("inputs:diffuse_texture").Get()
print(texture.path)
print(texture.resolvedPath)

Here’s what I got with an OmniPBR material:

1 Like