Is it possible to get the active strips in the NLA Editor with Python, in order to run a function on them?
$\begingroup$
$\endgroup$
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 = []
-
$\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
$\begingroup$
$\endgroup$
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)
-
$\begingroup$ Your code seems to give the selected strips, not the active strips. $\endgroup$ – rools Feb 28 '18 at 8:37
-