You can't actually move strips between NLA Tracks. Instead, you have to do it in two steps:
- Delete the strip from the old track.
- Add the strip to the new track.
This can be done in either order.
Once you have the new strip, you can modify the NlaStrip
itself to add transitions and modifiers. You can do this to any NlaStrip
once you've looked it up.
There is one small detail about adding a strip: you have to tell Blender where in the NlaTrack the strips should go. In my example, I'm placing the strips one frame after the end of last strip already in the NLaTrack
.
I start with a situation similar to yours: 3 tracks, each with a single strip.
I then execute this code:
import bpy
# Assume we want to deal with actions associated with the active object
object = bpy.context.active_object
tracks = object.animation_data.nla_tracks
# For a different set up, replace "NlaTrack.002" with the name of the destination track
dst_track = tracks["NlaTrack.002"]
# For a different set up, replace "NlaTrack.001" with the name of the source track.
src_track = tracks["NlaTrack.001"]
# Assume that the strip to be moved is the first strip on the track.
# We could, instead, simply select an action from bpy.data.actions and not bother
# with an additional strip
src_strip = src_track.strips[0]
# We really need the action, not the strip
action = src_strip.action
# Since we are "moving" the strip, we delete it from the src track
src_track.strips.remove(src_strip)
# The 2nd argument is the frame number where the action goes. It has to be an integer.
# We assume that it goes adjacent to the last strip already on the track.
new_strip = dst_track.strips.new(action.name, int(dst_track.strips[-1].frame_end+1), action)
# Now you can use new_strip to set transition or add modifiers. See the manual entry
# https://docs.blender.org/api/current/bpy.types.NlaStrips.htm for details on the fields
# for instance
# new_strip.blend_in = SOME_FRAME_NUMBER
# This is unnecessary for just "moving" a strip. Here only for completeness.
tracks.remove(src_track)
# This is just a repeat of the above, but applied to a different track.
src_track = tracks["NlaTrack"]
src_strip = src_track.strips[0]
action = src_strip.action
src_track.strips.remove(src_strip)
new_strip = dst_track.strips.new(action.name, int(dst_track.strips[-1].frame_end+1), action)
tracks.remove(src_track)
You didn't ask to show how to remove tracks, but in my example I do remove them. That's simply to show how it is done. After the code runs, the NLA editor looks like this: