Is it possible to get the active strips in the NLA Editor with Python, in order to run a function on them?


You can get the active NLA track, but the strips array has no property .active in the Python API. It's not exposed, but the active strip is known in the C code (note that the Active Strip panel is hardcoded).

All you can do with Python is to get all selected strips:

    selected_strips = [strip for strip in bpy.context.object.animation_data.nla_tracks.active.strips if strip.select]
except AttributeError:
    selected_strips = []
  • $\begingroup$ Thank you for your answer, it is as I thought when I looked the source. Too bad for my addon. $\endgroup$ – rools May 12 '14 at 12:18
import bpy

for i in bpy.data.objects:
    for j in i.animation_data.nla_tracks.values():
        for k in j.strips.values():
            if k.active:
  • $\begingroup$ Your code seems to give the selected strips, not the active strips. $\endgroup$ – rools Feb 28 '18 at 8:37
  • $\begingroup$ Yes. I use select instead active $\endgroup$ – user41149 Mar 1 '18 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.