Easier Way to Offset an Animation of an Object?
-
Hi,
Is there an easy way to offset an animation of an object?
For example, I have a position.x track keyframe to from 5 to 10.
I just want to offset it by 2 frames through python.
Is there a one liner to do it? c4d.MoveTrack(frame=2) or something?Haven't tried it but there is CCurve.MoveKey or something.
So it woud be like. Get Track. Get Curve. Get Key shenanigan. Loop through those keys. Loop through those curves etc.I just really want to offset it Track.
Is there an easier of doing that?P.S. And I think there's no sample code on how to do it in the forum or in the documentation.
-
Okay. Manage it figure moving it without using the MoveKey. Still verbose though
import c4d def main(): obj = doc.GetActiveObject() desc_x = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION, c4d.DTYPE_VECTOR, 0), c4d.DescLevel(c4d.VECTOR_X, c4d.DTYPE_REAL, 0)) track = obj.FindCTrack(desc_x) curve = track.GetCurve() key_count = curve.GetKeyCount() fps = 24 offset_frame = 2 for index, value in enumerate(range(key_count)): key = curve.GetKey(index) time = key.GetTime() frame = (time.GetFrame(fps)) new_frame = frame + offset_frame new_time = c4d.BaseTime(new_frame/fps) key.SetTime(curve, new_time) c4d.EventAdd() main()
-
Hey @bentraje,
Thank you for reaching out to us. That is the only way to do it as far as I know. APIs tend to require much more verboseness than user interfaces. And the Python Cinema 4D API is there quite harmless, try C++
Cheers,
Ferdinand -
yea python is much more forgiving than C++. i was just wondering if there was an already existing API for such task.