Context override for action stashing

Hello,

I need to find a way to stash some actions in NLA, using python API. Is there a way to do it. Currently, I can’t because I can’t find what data to override in context during bpy.ops call.

More general related question : Is there a way to know, for any operators, what are the context / overridden data that are needed to run the operator ?

Thanks :slight_smile:

1 Like

For anyone asking, I wrote this code that does same thing, but wihtout any ops call :

import bpy

def stash(obj, action, track_name, start_frame):
    # Simulate stash :
    # * add a track
    # * add an action on track
    # * lock & mute the track
    # * remove active action from object
    tracks = obj.animation_data.nla_tracks
    new_track = tracks.new(prev=None)
    new_track.name = track_name
    strip = new_track.strips.new(action.name, start_frame, action)
    new_track.lock = True
    new_track.mute = True
    obj.animation_data.action = None
    


# Test
stash(
    bpy.context.object, 
    bpy.context.object.animation_data.action, 
    bpy.context.object.animation_data.action.name,
    bpy.context.scene.frame_start)
1 Like

In order to find the right context for specific operator, you have to take a look at c sources.