HasSpline fails for attributes with spline and time samples

Hello,

As the title says, the function HasSpline in an attribute fails if that attribute has both splines and time samples. Is that expected? I’ve tested with usd 25.11 and 24.11

Consider the following code:

stage = Usd.Stage.CreateInMemory()

prim_path = "/TestPrim"

xform = UsdGeom.Xform.Define(stage, prim_path)

prim = xform.GetPrim()


translateXOp = xform.AddTranslateXOp()

translateYOp = xform.AddTranslateYOp()


timeFrames = [1.0, 5.0, 10.0]

xValues = [0.0, 5.0, 10.0]

yValues = [0.0, 3.0, 6.0]


spline = Ts.Spline()

knots = Ts.KnotMap()

for time, value in zip(timeFrames, xValues):

    knot = Ts.Knot()

    knot.SetTime(time)

    knot.SetValue(value)

    knots[time] = knot

spline.SetKnots(knots)


translateXAttr = translateXOp.GetAttr()

translateXAttr.SetSpline(spline)

translateYAttr = translateYOp.GetAttr()

translateYAttr.SetSpline(spline)



for time, value in zip(timeFrames, yValues):  # Removing this for loop makes HasSpline become true

    translateXAttr.Set(value, time)

    translateYAttr.Set(value, time)



print(f"translateX:")

print(f"  - Has Spline: {translateXAttr.HasSpline()}")

print(f"  - Has time samples: {translateXAttr.GetNumTimeSamples() > 0}")



print(f"translateY:")

print(f"  - Has Spline: {translateYAttr.HasSpline()}")

print(f"  - Has time samples: {translateYAttr.GetNumTimeSamples() > 0}")

Hey @barbalt,

I believe this is expected behavior. The documentation on HasSplinestates:

Returns true if this attribute has a spline as the strongest value source.

If we refer to section 12.3.2 of v1.0.1 of the Core Specification, which covers time-based attribute resolution, it states that:

Time Samples have higher priority over Spline evaluation or Value clips.

So if timeSamples and spline are both authored on the same spec, the timeSamples will be considered stronger. Therefore, HasSpline will return false.

Hey @jackohoeg thanks for the reply.

I know that USD would prefer to use the time samples over the spline when both are authored, but we can’t retrieve the spline information when that’s the case seems strange to me..

Your answer makes sense though.. This seems to be like the intended behavior..