Timeline Parsing with Python

List all element Block and Key inside the timeline

PythonTimelineParsing PythonTimelineParsing PythonTimelineParsing PythonTimelineParsing

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}")

Once you know how to parse the blocks and keyframes you can start to Timeline Manipulation with Python .