# Resolving relative paths from Sdf.Layer.subLayerPaths

**URL:** <https://forum.aousd.org/t/resolving-relative-paths-from-sdf-layer-sublayerpaths/838>\
**Category:** USD\
**Created:** [October 23, 2023, 8:39pm UTC](https://forum.aousd.org/t/resolving-relative-paths-from-sdf-layer-sublayerpaths/838 "2023-10-23T20:39:38Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![spiff](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/spiff/32/22_2.png) [@spiff](https://forum.aousd.org/u/spiff)\
**Post date:** [November 3, 2023, 10:06pm UTC](https://forum.aousd.org/t/resolving-relative-paths-from-sdf-layer-sublayerpaths/838/3 "2023-11-03T22:06:36Z")

</div>

@jackohoeg makes some great points about absolute paths and contexts! The `ComputeAbsolutePath()` solution should always work (though it, too, may be affected by an `ArResolverContext`, so if there is an active/session context that is _not_ already bound, you’d want to first bind it as in the second example.

The second example won’t work properly for “anchored paths” (e.g. with the ArDefaultResolver, those that start with “./” like `@./anchored/layer.usd@`). As of Ar 2.0, the preferred pattern to do this would be something like:

```auto
layer = Sdf.Layer.FindOrOpen("/path/to/asset.usd")
resolver = Ar.GetResolver()
lyrResolved = layer.resolvedPath
ctx = resolver.CreateDefaultContextForAsset(lyrResolved)

with Ar.ResolverContextBinder(ctx):
    for sublayer in layer.subLayerPaths:
        print(resolver.Resolve(resolver.CreateIdentifier(sublayer, lyrResolved)))

```

---

_[View the full topic](https://forum.aousd.org/t/resolving-relative-paths-from-sdf-layer-sublayerpaths/838)._
