0
$\begingroup$

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

$\endgroup$
1
$\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
| improve this answer | |
$\endgroup$
  • $\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$ – VirtualTurtle Jan 9 '18 at 19:38
  • $\begingroup$ Whoops, fixed it. $\endgroup$ – batFINGER Jan 10 '18 at 1:13

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.