Setting value of keyframe not working



  • On 05/10/2015 at 13:06, xxxxxxxx wrote:

    I have an Alembic object that has animation on it. I don't want to adjust that.

    I want to be able to keyframe the "Start of Animation" option that's in the Object tab.

    I can add a track, get the curve, and add a key with no errors popping up, I just can't get the value to go to anything else beside "1 F"

    I think my issue is that the CKey.SetValue requires a curve and a float and the end result needs to be a baseTime object.

    Here's a snippet of the code I have currently.

    doc = c4d.documents.GetActiveDocument()
    sel = doc.GetActiveObject()
    startFrame = 200
      
    track = c4d.CTrack( sel, c4d.DescID( c4d.ALEMBIC_START_DELAY ))
    sel.InsertTrackSorted( track )
    curve = track.GetCurve()
    fKey = c4d.CKey()
    track.FillKey( doc, sel, fKey )
    fKey.SetTime( curve, c4d.BaseTime( startFrame, fps))
    fKey.SetValue( curve, startFrame )
    curve.InsertKey( fKey )
    c4d.EventAdd()
    

    This code doesn't generate errors, it just doesn't add the new value of 200.
    What am I missing or doing wrong?



  • On 06/10/2015 at 04:48, xxxxxxxx wrote:

    Hi Herbie,

    the CTrack needs to be set up correctly with the datatype:

    track = c4d.CTrack(sel, c4d.DescID(c4d.DescLevel(c4d.ALEMBIC_START_DELAY, c4d.DTYPE_TIME))
    

    And as the keyframe is of type Basetime, you need to use SetGeData() to set the value:

    fKey.SetGeData(curve, c4d.BaseTime(startFrame, fps))
    

    There's also another thread Questions regarding Keys/CKey, which may provide you some additional infos.



  • On 06/10/2015 at 10:25, xxxxxxxx wrote:

    Aww yes! This helps tremendously. There's no doubt I will use this all of the time now.

    Thank you!


Log in to reply