Timeline Parsing with Python

Timeline Parsing with Python

List all element Block and Key inside the timeline

For now, it's not possible to create new tracks, the parameter or block of an element needs to be already in the timeline

elementTracks and parameterTracks

In this script below we first assign the main timeline to "t" and then we iterate onto the elementTracks and parameterTracks to list them
t = script.parentElement.mainAnimation

for element, track in t.elementTracks.items():
    elt = element.get()
    blocks = track.blocks
    print(f"Element {elt.getFriendlyName()} -> {len(blocks)} blocks")
    for block in blocks:
        print(f"  Block {block.position} {block.length}")

for object, track in t.parameterTracks.items():
    parameter = object.get()
    print(f"Parameter {parameter.getFriendlyName()}")
    f = track.function
    for key in f.keyframes:
        print(f"  Keyframe {key.position} {key.key}")

time markers

t = script.parentElement.mainAnimation
for marker in t.timeMarkers:
    print(f"Marker: {marker.label} at {marker.position}")
One you know how to parse the blocks and keyframes you can start to Timeline Manipulation with Python Create move edit Block and Keyframe inside Timeline Read More

See Also: