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:
So far my plan is to:
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
max(enumerate(props), key = lambda tup: len(tup[1]))
This gives you a tuple containing (index, list)
of the longest list in props.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With