I am storing animation key frames from Cinema4D(using the awesome py4D) into a lists of lists:
props = [lx,ly,lz,sx,sy,sz,rx,ry,rz]
I printed out the keyframes for each property/track in an arbitrary animation and they are of different lengths:
track Position . X has 24 keys
track Position . Y has 24 keys
track Position . Z has 24 keys
track Scale . X has 1 keys
track Scale . Y has 1 keys
track Scale . Z has 1 keys
track Rotation . H has 23 keys
track Rotation . P has 24 keys
track Rotation . B has 24 keys
Now if I want to use those keys in Blender I need to do something like:
- go to the current frame
- set the properties for that key frame( can be location,rotation,scale) and insert a keyframe
So far my plan is to:
- Loop from 0 to the maximum number of key frames for all the properties
- Loop through each property
- Check if it has a value stored for the current key, if so, go to the frame in Blender and store the values/insert keyframe
Is this the best way to do this ?
This is the context for the question.
First I need to find the largest list that props stores. I'm new to python and was wondering if there was a magic function that does that for you. Similar to max(), but for list lengths.
At the moment I'm thinking of coding it like this:
//after props are set
lens = []
for p in props: lens.append(len(p))
maxLen = max(lens)
What would be the best way to get that ?
Thanks