Hello,
I am trying to use CCurve.FindPrevUnmuted & CCurve.FindNextUnmuted. In this example based on @m_magalhaes CreateKey
demo, I'm passing the middle key's index to these respective methods. Both return the middle key which is unexpected. Based on the documentation, FindPrevUnmuted should return the previous unmuted key and FindNextUnmuted should return the next unmuted key using the index parameter as the starting index. Am I using this incorrectly or is something else going wrong? Thank you!
import c4d
def CreateKey(curve, time, value, interpolation):
keyDict = curve.AddKey(time)
if keyDict is None:
raise MemoryError("Failed to create a key")
key = keyDict["key"]
keyIndex = keyDict["nidx"]
key.SetValue(curve, value)
curve.SetKeyDefault(doc, keyIndex)
key.SetInterpolation(curve, interpolation)
return key, keyIndex
def main():
obj = c4d.BaseObject(c4d.Ocube)
trackY = c4d.CTrack(obj, c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION, c4d.DTYPE_VECTOR, 0),
c4d.DescLevel(c4d.VECTOR_Y, c4d.DTYPE_REAL, 0)))
curveY = trackY.GetCurve()
keyA, keyAIndex = CreateKey(curveY, c4d.BaseTime(0), value=0, interpolation=c4d.CINTERPOLATION_SPLINE)
keyBTime = c4d.BaseTime(10, doc.GetFps())
keyB, keyBIndex = CreateKey(curveY, keyBTime, value=100, interpolation=c4d.CINTERPOLATION_SPLINE)
bt = c4d.BaseTime(5, doc.GetFps())
keyDict = curveY.AddKeyAdaptTangent(bt, True, True)
# -------------- #
prevKey = curveY.FindPrevUnmuted(keyDict["nidx"])
nextKey = curveY.FindNextUnmuted(keyDict["nidx"])
print("prevKey index:",prevKey[1],", prevKey value:",prevKey[0].GetValue()) #returns keyDict's values
print("nextKey index:",nextKey[1],", nextKey value:",nextKey[0].GetValue()) #returns keyDict's values
# -------------- #
obj.InsertTrackSorted(trackY)
doc.InsertObject(obj)
c4d.EventAdd()
if __name__ == '__main__':
main()