0
$\begingroup$

I just imported a bunch of actions from different files into one blend, but the GLTF exporter can't locate them without them being in the NLA stash. (There used to be a plugin that would export all actions to the GLTF, but 2.8 won't add it to the addon list.)

I tried this:

import bpy

ob = bpy.context.object

if ob.animation_data is None:
    ob.animation_data_create()

ad = ob.animation_data

for action in bpy.data.actions:
    ad.action = action
    bpy.ops.action.stash()

And that just caused:

RuntimeError: Operator bpy.ops.action.stash.poll() failed, context is incorrect

And I haven't been able to find anything on how to fix it for this specific function.

How can I do this?

$\endgroup$
0
$\begingroup$

This does it, but i can't actually unregister the addon.

It needs to be run from the space menu with the cursor in the dopesheet in action mode.

bl_info = {
    "name" : "stash all",
     "catagory" : "Action",
}

import bpy

class StashAll(bpy.types.Operator):
    """My Stashing Script"""
    bl_idname = "action.stash_all"
    bl_label = "stash all"
    bl_options = {'REGISTER'}

    def execute(self, context):
        ob = bpy.context.object

        if ob.animation_data is None:
            ob.animation_data_create()

        ad = ob.animation_data

        for action in bpy.data.actions:
            ad.action = action
            track = ad.nla_tracks.new();
            track.strips.new(action.name, action.frame_range[0], action)

        ad.action = null

        return {'FINISHED'}

def register():
    bpy.utils.register_class(StashAll)

def unregister():
    bpy.utils.unregister_class(StashAll)

if __name__ == "__main__":
    register()
| improve this answer | |
$\endgroup$
  • $\begingroup$ Hi! Care to share more details about this? I have your exact same problem but I'm not able to load this script. How can I add this to blender? $\endgroup$ – Setzer22 Nov 1 at 19:20
0
$\begingroup$

For Setzer22's reference: this is the script with typos fixed and in non-addon form. Paste it into the text editor and hit the Run Script button.

import bpy

ob = bpy.context.object

if ob.animation_data is None:
    ob.animation_data_create()

for action in bpy.data.actions:
    track = ob.animation_data.nla_tracks.new()
    track.name = action.name
    track.strips.new(action.name, action.frame_range[0], action)
| improve this answer | |
$\endgroup$

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.