Set Start & End based on Actions

Hi,

Is there any way to automatically set Start & End frames based on current selected Action?
Is there any quicker way to preview animation loops?

Thanks!

P.S.: Found “Autoset preview range” but it isn’t that automatic, plus adds an extra key frame at the end… is it a bug or intended to be like that?

1 Like

Is there any way to automatically set Start & End frames based on current selected Action?

A python script could this for you with the click of one button. I know how it would work, a simple operator that once executed would check the start & end frames of the action, then set the preview range accordingly. It would be a simple script for an experienced blender python programmer to write, but I’m not that person.

Is there any quicker way to preview animation loops?

If you mean to improve the speed of preview animations in the 3d view, as in increase the FPS of playback, then yes, lots of ways. Search the forum, been asked several times. Basically, the best way to increase 3d view speed is to reduce the amount of data blender has to display in the 3d view. Get rid of all back ground stuff that isn’t needed to see the animation. Reduce subsurf modifiers to zero view levels, only show what is needed to see the animation.

I’ve never used autoset preview range before, so I can’t comment…

Hope this helps,
Randy

Thanks Randy, I guess I shall look for a python programmer!

Bit late to the party but this might help anyone facing the same problem,

As of blender 4.2, you can do this via script as such:

import bpy

def set_frame_range_for_action():
    # Check if there is an active action
    if bpy.context.object.animation_data and bpy.context.object.animation_data.action:
        action = bpy.context.object.animation_data.action

        # Set the scene frame range
        bpy.context.scene.frame_start = int(action.frame_range[0])
        bpy.context.scene.frame_end = int(action.frame_range[1])

# Run the function
set_frame_range_for_action()

Go to the scripting tab, paste the code and press the run button

If you don’t want to do this repeatedly you can also create an addon, here’s the script for that:

bl_info = {
    "name": "Auto Action Start End",
    "category": "Animation"
}

import bpy

# To keep track of the previously selected action name
prev_action_name = ""


def update_active_action(scene):
    global prev_action_name

    # Check if there is an object with animation data
    if (bpy.context.object and bpy.context.object.animation_data and bpy.context.object.animation_data.action):
        action = bpy.context.object.animation_data.action
        action_name = action.name

        # Print action name only if it's different from the previous one
        if action_name != prev_action_name:

            # Set frame start and frame end
            action = bpy.context.object.animation_data.action
            bpy.context.scene.frame_start = int(action.frame_range[0])
            bpy.context.scene.frame_end = int(action.frame_range[1])

            prev_action_name = action_name
    elif prev_action_name:
            prev_action_name = ""


def register():
    # Register the handler function
    bpy.app.handlers.depsgraph_update_post.append(update_active_action)


def unregister():
    # Unregister the handler function
    bpy.app.handlers.depsgraph_update_post.remove(update_active_action)


if __name__ == "__main__":
    register()
1 Like