1
$\begingroup$

Is there an easy way to select a specific NLA Track with a python script?

$\endgroup$

1 Answer 1

3
$\begingroup$

Set the NLATrack.select property to true.

Sample script, selects all tracks, on context object, which have a name beginning with "Nla" The zeroth position track is set to active.

import bpy
from bpy import context 

ob = context.object
ad = ob.animation_data
if ad:
    for i, track in enumerate(ad.nla_tracks):
        # select all whose name starts with "Nla"
        track.select = track.name.startswith("Nla")
        # make active track if in pos 0
        if track.select and not i:
            ad.nla_tracks.active = track
$\endgroup$
2
  • $\begingroup$ It gives me an error in the console "AttributeError: bpy_struct: attribute "active" from "NlaTrack" is read-only" regarding line 11. The whole reason I'm doing this is to separate different NLA tracks into separate objects, if you know an easier way than duplicating, removing animations, then re-adding, please let me know. $\endgroup$ Commented Jan 9, 2018 at 19:38
  • $\begingroup$ Whoops, fixed it. $\endgroup$
    – batFINGER
    Commented Jan 10, 2018 at 1:13

You must log in to answer this question.

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