# Using a parent prim's name in reference as a variable?

**URL:** <https://forum.aousd.org/t/using-a-parent-prims-name-in-reference-as-a-variable/1960>\
**Category:** USD\
**Created:** [November 1, 2024, 12:55am UTC](https://forum.aousd.org/t/using-a-parent-prims-name-in-reference-as-a-variable/1960 "2024-11-01T00:55:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![patricknagle](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@patricknagle](https://forum.aousd.org/u/patricknagle)\
**Post date:** [November 1, 2024, 12:55am UTC](https://forum.aousd.org/t/using-a-parent-prims-name-in-reference-as-a-variable/1960/1 "2024-11-01T00:55:33Z")

</div>

I am looking at porting features of our internal scene description to USD (or at least evaluating the differences between them - which there are many).

One of the features of our scene description is a variable syntax which allows us to define the scene graph location (/character/bobA01/main) and which asset(s) (a usd file for shaders, or a model etc) _may exist or may not_ (effectively its a templating mechanism) on the prim/scene graph location.

One of the features of this is that our “asset nodes” which resolve to asset versions on disk can use variables to define the resulting posix file path.

As a side note we have no “Asset.usda” file for an “Asset” our definintion of “Asset” is pretty loose and is made up of muliple “nodes” that are stacked next to each other which in turn build a payload/reference list.

In the example above we may have asset nodes for:

- model
- anim-cache
- creature-cache
- materials

these are payloads which contain a simple internal struture based on the ASWF Asset guilelines (their default prim is /ASSET)

The resulting file paths end up payloaded onto /character/bobA01 and compose together as excepted.

The animation is a shot cache which contains only the points which have been deformed and is layered with the model (asset).

_Our variable syntax uses the parent hierarchy to determine the asset path locations._

The UI we have has variables in it and it forms a dict of tags basically…those tags are evaultaed by the expression engine and it gives back a path

- /asset/$job/$seq/$shot/components/$node[-2].label-$node[-1].label/usdCache/anim

so when we evaluate that with the parent(s): /character/bobA01/main it becomes:

- /asset/USD/TST\_0100/TST\_0100\_0010/components/bobA01-main/usdCache/anim

If we need two _bobs_ we simply duplicate /character/ **bobA01** and it becomes /character/ **bobA02** and the anim-cache location becomes:

- /asset/USD/TST\_0100/TST\_0100\_0010/components/bobA02-main/usdCache/anim

Currently we basically make everything unique - but the gotcha is these two share the same shaders, model, procedural fur etc.

Is there any way to use a parent prim’s name (when its _referenced_) in an SdfPath SdfReference/Payload?

Appologies if that makes zero sense!

---

<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, 2024, 1:40am UTC](https://forum.aousd.org/t/using-a-parent-prims-name-in-reference-as-a-variable/1960/2 "2024-11-03T01:40:20Z")

</div>

Hi @patricknagle ! Question makes sense for sure. However, it’s not a behavior USD supports, for a couple of reasons. Starting from the position of wanting to provide predictable results, composition itself makes the prospect a little challenging, **especially** when you bring sub-root references and non-global inherits into the picture. When we sub-root reference something, we make sure to evaluate all the composition arcs on ancestor prims of the referenced prim, to ensure it gets all the opinions/contributions you’d expect. So _presumably_ you’d want any references in that layerStack to use that layerStack’s namespace… but then the ancestral namespace is hidden/gone in the referencing stage, so it’d be a little mystifying figuring out how you get the substitution you did. But then also, it seems like for _most_ reference substitutions you’re looking to use the root layer / stage’s namespace for parenting, which I think is different from the needs of subroot references.

Then there’s namespace editing… if you move a model-reference-prim from one scope to another, would you be expecting the model might radically change in response?

For non-composition asset paths (e.g. textures, volumes, etc), we hope to be getting to the project soon that will allow primvar substitution in the asset paths, and primvars can be inherited hierarchically down namespace. But that mechanism could never be applied for composition arcs, because it assumes lots and lots of scenegraph, value resolution, and schema behavior that is much higher-level than composition.

Asset resolvers, by design, can’t get access to any “stage level” data other than the asset path itself that is being resolved. I’m unable to come with any ideas about how you might get anything close to this behavior in USD, I’m afraid!

---

<div class="post-metadata">

**Author:** ![patricknagle](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@patricknagle](https://forum.aousd.org/u/patricknagle)\
**Post date:** [November 3, 2024, 11:30am UTC](https://forum.aousd.org/t/using-a-parent-prims-name-in-reference-as-a-variable/1960/3 "2024-11-03T11:30:36Z")

</div>

Hey,

I suspected as much. Our internal scene description does not have any composition element to it. We do have a similar ability to “scene reference” a sub-path into another scene description and this has brought up issues with the variable syntax in our asset paths. Especially when a node is pulling the name/attribute off a node 3-4 levels up the source scene description and then it’s being referenced into a scene description with only 2 levels of parents!

Regarding  
Then there’s namespace editing… if you move a model-reference-prim from one scope to another, would you be expecting the model might radically change in response?

We can’t really move the model/shader etc reference in our scene description without “localising” the entire thing (which looses it’s connection to its original content). We _can_ rename/move the parent nodes like /character/bobA01 to /characters/BobA01 which would effect the asset paths resolution. This is purely a convention that has become common place and built on…it tightly couples asset paths and the scene graph together and makes duplicating easy but can lead to things breaking and people not understanding why.

Thanks as always! The primvar stuff sounds super useful! Is there a proposal for that one that I could read?

Patrick

---

<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 5, 2024, 2:09am UTC](https://forum.aousd.org/t/using-a-parent-prims-name-in-reference-as-a-variable/1960/4 "2024-11-05T02:09:44Z")

</div>

No proposal yet for primvar substitutions, sorry.
