# Getting the fallback value from a UsdAttribute

**URL:** <https://forum.aousd.org/t/getting-the-fallback-value-from-a-usdattribute/2123>\
**Category:** USD\
**Created:** [January 7, 2025, 6:46pm UTC](https://forum.aousd.org/t/getting-the-fallback-value-from-a-usdattribute/2123 "2025-01-07T18:46:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![James](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/james/32/168_2.png) [@James](https://forum.aousd.org/u/James)\
**Post date:** [January 7, 2025, 6:46pm UTC](https://forum.aousd.org/t/getting-the-fallback-value-from-a-usdattribute/2123/1 "2025-01-07T18:46:19Z")

</div>

Hey there!

Is there a way I can get the value of the fallback from a UsdAttribute on a composedStage? There is `hasFallbackValue()` which will tell me whether it has one, but I can’t seem to find a nice way to get the fallback value.

If no nice way is there any reasons why? The alternative being (from looking at the source) I’ll likely have to cycle through all the applied schemas on the prim and query them for the fallback values…(feels like it’s going to be slow) I can only assume this was done for a reason though, hence questioning whether there’s specific reasons as to why to avoid this. Especially with the PrimDefinition being purposefully hidden away as it is…

It doesn’t seem like it’d be too expensive, since the HasFallbackValue does 99% of the work, just it doesn’t return the Value any further?

```auto
bool
UsdAttribute::HasFallbackValue() const
{
    UsdPrimDefinition::Attribute attrDef =
        _GetStage()->_GetSchemaAttribute(*this);
    return attrDef && attrDef.GetFallbackValue<VtValue>(nullptr);
}

```

Cheers,  
James

---

<div class="post-metadata">

**Author:** ![denglesson](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/denglesson/32/600_2.png) [@denglesson](https://forum.aousd.org/u/denglesson)\
**Post date:** [January 9, 2025, 12:55pm UTC](https://forum.aousd.org/t/getting-the-fallback-value-from-a-usdattribute/2123/2 "2025-01-09T12:55:41Z")

</div>

Hi James,

Sounds like a GetFallbackValue() might have been nice here for convenience. Not sure about the performance but as you mentioned most of the work is done in the attrDef anyway.

You can get the the fallbackvalue in this way though:

prim = attr.GetPrim()  
primDef = prim.GetPrimDefinition()  
defaultValue = primDef.GetAttributeFallbackValue(attr.GetName())

Cheers,  
Dan

---

<div class="post-metadata">

**Author:** ![James](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/james/32/168_2.png) [@James](https://forum.aousd.org/u/James)\
**Post date:** [January 9, 2025, 3:10pm UTC](https://forum.aousd.org/t/getting-the-fallback-value-from-a-usdattribute/2123/3 "2025-01-09T15:10:04Z")

</div>

> [@denglesson](#):
>
> primDef.GetAttributeFallbackValue(attr.GetName())

Perfect, I can’t believe I missed that `GetPrimDefinition` function on the UsdPrim!  
Thank you Dan!
