list NLA info (for game reference)

This is my first script and I’m happy to at least have something working. Often when exporting animated characters for rigs, you need to know which animations start and end at which frames. I’ve been working on a game using spritify to export sprites, but knowing if I wrote by hand which animations started at which frames I’d screw up plenty of times, I figured out how to access the data automatically. It currently just prints to console which is good enough for me for now, but I’d like to set it up to export a txt along with any exported sprites with spritify.

import bpy

#exports some info from NLA editor in text, like strip names, start and length || by Teh_Bucket
names = []
theData = []
nlaStrips = bpy.context.object.animation_data.nla_tracks[0].strips
#gets all the info and puts it in theData and names
for i in range(0, len(nlaStrips)):
    names.append(nlaStrips[i].name)
    theData.append([nlaStrips[i].frame_start, nlaStrips[i].frame_end])

for i in range(0, len(names)):
    print(i,names[i])

for i in range(0, len(theData)):
    print(theData[i][0], theData[i][1])

NOTE: it currently only works if you have the armature selected, and all the animations are in the first NLA track

How it looks in action: