KeyFrame User Data from Xpresso driven User Data
-
To whom it may concern,
I have an object that has two user data fields.

I know that an Xpresso-driven user data field can not be animatable using keyframes, which is why I have the user data field keyframes. If I manually put the keyframes in the user data field keyframes with the same data as the Xpresso Driven user data field, everything works. However, I want it to make it work with a Python script, so I do not need to do the keyframes manually. I tried with this script:import c4d from c4d import gui def main(): doc = c4d.documents.GetActiveDocument() obj = doc.SearchObject('Cube') desc_id_keyframes = None value = None user_data_container = obj.GetUserDataContainer() for desc_id, bc in user_data_container: if bc[c4d.DESC_NAME] == "Xpresso Driven": value = obj[desc_id] elif bc[c4d.DESC_NAME] == "KeyFrames": desc_id_keyframes = desc_id print(value) print(desc_id_keyframes) track = c4d.CTrack(obj, desc_id_keyframes) if not obj.FindCTrack(desc_id_keyframes): obj.InsertTrackSorted(track) curve = track.GetCurve() time = c4d.BaseTime(0, doc.GetFps()) result = curve.AddKey(time) key = result["key"] key.SetValue(curve, value) c4d.EventAdd() if __name__=='__main__': main()However, the keyframe does not get inserted:

What am I doing wrong?
Thanks in advance for the help.
Regards,
Joel Johera -
Solved.
I need to change this part:
track = obj.FindCTrack(desc_id_keyframes) if track is None: track = c4d.CTrack(obj, desc_id_keyframes) obj.InsertTrackSorted(track) -
Hey @JoelJohera,
it is kind of hard to follow your question and solution, as the former lacks a scene for context and for the latter I am not quite sure what you fixed. But when it works for you I am happy

Cheers,
Ferdinand