1
$\begingroup$

Is it possible to create transition between clips with python?

Transition

$\endgroup$
0

1 Answer 1

1
$\begingroup$

This is an example of how to do it, using bpy.ops.nla.transition_add

import bpy

# Generate an override that can be used for this call.
win = bpy.context.window
scr = win.screen
areas  = [area for area in scr.areas if area.type == 'NLA_EDITOR']
regions   = [region for region in areas[0].regions if region.type == 'WINDOW']
override = { 'area': areas[0], 'region' : regions[0] }

# Replace this line with one that selects the object that has the NLA Tracks
object = bpy.context.active_object

# Replace this line with one that selects the NLA Track you want.
track = object.animation_data.nla_tracks['NLaTrack']

# Replace the next two lines with ones that select the desired strips.
# They must be adjacent.
# No other strips should be selected so you may have to deselect all first.
track.strips[0].select = True
track.strips[1].select = True

# Add the transition, using the override calculated earlier.
bpy.ops.nla.transition_add(override)

The key is that you have to select two adjacent NLA strips and that the bpy.ops.nla.transition_add call needs a context override.

3.2 Update

Context overrides are deprecated in Blender 3.2 and are scheduled to be removed in Blender 3.3 The replacement is temp_override. The manual has examples of how to use the new function.

$\endgroup$
3
  • $\begingroup$ Thank you Marty! But is there solution without selection these clips? Something similar to: bpy.types.NlaStrips.new( ... ) I am creating simple addon for duplicate whole NLA from one object to other. I can easily copy all clips with settings, but I don't know how to copy the transitions. It is releated to this: blender.stackexchange.com/a/163875/1910 $\endgroup$
    – Cenda
    Commented May 12, 2022 at 17:01
  • $\begingroup$ bpy ops tend not to be very flexible and there's really no way to add a transition without knowing where it goes, as far as I know. Unfortunately "where it goes" is between two selected strips. But copying might be a different problem. Maybe ask a separate question about copying between two tracks? $\endgroup$ Commented May 12, 2022 at 22:38
  • $\begingroup$ @Cenda I just added an answer to the other question that should handle your transition case. $\endgroup$ Commented May 12, 2022 at 23:53

You must log in to answer this question.

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