3
$\begingroup$

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

$\endgroup$

2 Answers 2

3
$\begingroup$

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:

try:
    selected_strips = [strip for strip in bpy.context.object.animation_data.nla_tracks.active.strips if strip.select]
except AttributeError:
    selected_strips = []
$\endgroup$
1
  • $\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, 2014 at 12:18
2
$\begingroup$
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:
                print(k)
$\endgroup$
2
  • $\begingroup$ Your code seems to give the selected strips, not the active strips. $\endgroup$
    – rools
    Feb 28, 2018 at 8:37
  • $\begingroup$ Yes. I use select instead active $\endgroup$
    – user41149
    Mar 1, 2018 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .