So I've worked on a local add-on that would allow me to adjust the start frame and the end frame of the playback loop. I created an enum list with three options: default, A, and B. Basically want I want to do is:

  1. Adjust the start and end of the playback by selecting either default, A, or B on the add-on
  2. A's playback would loop from 60-180 in the first time and then loop from 120-180. Same with B starting from 180-300 the first time and then from 240-300

If I select 'default' and play the animation it would work perfectly. But if I select 'default' again after I select either A or B, the first playback loop will go from 0-60, and then both start and end are at 120. Every time the animation will go from 0 to 120. Then clicking on A or B is even worse, the animation will run the desired range in the first time, then run from 0-120.

It seems like something is being overridden here. I'm not exactly sure how and why. Can anyone please help?

 def execute(self, context):
    # execute() is called by blender when running the operator.

    ## helper function used to modify the start keyframe of the second loop
    def keep(command):
        scene = bpy.context.scene
        if scene.frame_current == scene.frame_end:
            if command == 'A':
                scene.frame_start = 120
            elif command == 'B':
                scene.frame_start = 240
                raise TypeError("Invalid Input Command")

    def handlerA(scene):
    def handlerB(scene):

    if self.options == 'default':
        bpy.context.scene.frame_start = 0
        bpy.context.scene.frame_current = 0
        bpy.context.scene.frame_end = 60
    elif self.options == 'A':
        bpy.context.scene.frame_start = 60
        bpy.context.scene.frame_current = 60
        bpy.context.scene.frame_end = 180
    elif self.options == 'B':
        bpy.context.scene.frame_start = 180
        bpy.context.scene.frame_current = 180
        bpy.context.scene.frame_end = 300

    return {'FINISHED'}            # this lets blender know the operator finished successfully.

1 Answer 1


Never mind, apparently changing the start and end key frames in handlers were messy and it would only be changed once. Make the script changes the current key frames and avoid abstracting the handler methods would solve the problem.

  • 1
    $\begingroup$ Could you elaborate on Make the script changes the current key frames and avoid abstracting the handler methods and then accept your own answer. $\endgroup$
    – Leander
    Dec 13, 2017 at 9:19

You must log in to answer this question.

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