0
$\begingroup$

is there a way to customize the Alt + Mouse Wheel which works in most editors that when you reach the end frame you can jump back to start?
is it something I don't see in settings or do I need a script for that and how can I do it by script if so .

I'm not looking for other hotkeys to jump to start and end, I wanna use that specific hotkey and move in timeline normally but instead of passing by the end frame, jump back to start or being stuck at the start get back to end frame...
like in a walk cycle animation this way you can easily see the transition between end and starting over

$\endgroup$
4
  • $\begingroup$ SHIFT-Left arrow takes you to the start and SHIFT-Right arrow to the end of the timeline. $\endgroup$
    – John Eason
    Sep 15 at 8:25
  • $\begingroup$ @JohnEason yeah but for that you need to take one of your hands of the mouse or keyboard . if there was a way to do it just like I said that would be nice $\endgroup$
    – mma78
    Sep 15 at 9:29
  • $\begingroup$ can do most things in blender via a script Please clarify what you do want, not what you don't. Are we talking about scrubbing the time line with the scroll wheel and if it goes past end points reverts to the other? $\endgroup$
    – batFINGER
    Sep 15 at 15:24
  • $\begingroup$ @batFINGER question is very self explaining . that link you sent helped alot i just need to look up for more stuff to make the script for it $\endgroup$
    – mma78
    Sep 15 at 15:28
0
$\begingroup$

Edit the keymap.

As commented by @John Eason these are already mapped to SHIFT and left arrow for go to start, and right to end.

Can search for keymaps by keypress

enter image description here

Or name, if unsure hover over the button that does it

enter image description here

Once found change to suit.

enter image description here

Here I've altered it to ALT + middle mouse click.

Save User Preferences to make change permanent.

$\endgroup$
4
  • $\begingroup$ i know i can change the hotkey for that but what im saying is to change the behavior of a specific hotkey when something happens. it is a small change but i guess that way its easier for something like a walk cycle . so this wont be the answer $\endgroup$
    – mma78
    Sep 15 at 14:55
  • $\begingroup$ Clarify any details by editing it into your question. Do you want to match the frame range to current objects action range rather than scene. There are answers relating to that question. $\endgroup$
    – batFINGER
    Sep 15 at 14:58
  • $\begingroup$ yeah maybe that would work $\endgroup$
    – mma78
    Sep 15 at 15:05
  • $\begingroup$ blender.stackexchange.com/questions/27889/… $\endgroup$
    – batFINGER
    Sep 15 at 15:13
-1
$\begingroup$

Why Even Do this

there are several options to monitor the transitions in frames but in my experience the best way is to use the mouse scroll wheel since you have more control over speed and its easy to use . It's like classic animation when animators flip back and forth paper between their fingers.

but when you are making a cycle animation which is used a lot in game animations, there is one thing that is annoying and its how you cant see the transition from end frame to starting over as easy.

it is a small change but I think it worth it.


So here is a way to make this work
basically we disable the old behavior and make a new one that does the same old behavior and just checks for the end and start frame then does the expected thing

Disable Default Hotkeys

Edit -> Preferences -> Keymap

  1. set the search type to Key-Binding
  2. search for "wheel"
  3. scroll a bit and find Frames section
  4. and disable both Frame Offsets

How to Make The Script

So to make a function and assign a hotkey to it we need an Operator
which has an execute function where our logic will be
and when we assign a hotkey to the operator ,when the keys are pressed(event happens) this function will be called

we want to make this as an add-on ,so we add some info about it in bl_info

First Step

as you can see the operator class has some basic properties like an ID , label and more that we can fill in and some more info

bl_info = {
    "name": "Better_Scroll_Time",
    "blender": (2, 80, 0),
    "category": "Object",
}

import bpy
from bpy.props import *
import addon_utils


class ScrollWheelTime(bpy.types.Operator):
    """Sets the time in range"""      # Use this as a tooltip for menu items and buttons.
    bl_idname = "object.scroll"        # Unique identifier for buttons and menu items to reference.
    bl_label = "Better Time Scroll Wheel"         # Display name in the interface.
    bl_options = {'REGISTER', 'UNDO'}  # Enable undo for the operator.
    
    def execute(self, context):        # execute() is called when running the operator.    
        # logic


        return {'FINISHED'}            # Lets Blender know the operator finished successfully.

Execute

direction: IntProperty()  #outside of execute function as a class member

    def execute(self, context):
        #logic
        scn = context.scene 
        current_frame = scn.frame_current
        current_frame+=self.direction
        scn.frame_set(current_frame)
           
        if not scn.frame_start <= current_frame <= scn.frame_end:
            scn.frame_set(scn.frame_start if self.direction>=1 else scn.frame_end)

        return {'FINISHED'}        

  • so if you look at blender keymaps in Preferences you can find Operations with some properties that we can provide too, with bpy.props functions like IntProperty()
  • we need a reference to the scene we are in to access things like start and end frame of the scene
  • increase or decrease current frame with the amount of direction which will be set to +1 and -1 based on the shortcut
  • if current frame is not between start and end frame of the scene based on the direction we decide where to put the frame cursor
  • we tell blender this operation is finished

Register

addon_keymaps = []                 #outside of function


def register():      
    bpy.utils.register_class(ScrollWheelTime)
    # Add the hotkey
    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon
    if kc:
        km = wm.keyconfigs.addon.keymaps.new(name = "Window",space_type='EMPTY', region_type='WINDOW')
        km_up = km.keymap_items.new(ScrollWheelTime.bl_idname, type='WHEELUPMOUSE', value='PRESS', alt=True)
        km_down = km.keymap_items.new(ScrollWheelTime.bl_idname, type='WHEELDOWNMOUSE', value='PRESS', alt=True)
        
        km_up.properties.direction = -1     # setting the default property value for wheel up
        km_down.properties.direction = +1    # setting the default property value for wheel down
        
        addon_keymaps.append((km, km_up))
        addon_keymaps.append((km, km_down))
  • here we register our operation class so we can use if as an addon
  • then we make a keymap using wm.keyconfigs.addon.keymaps.new and set its parameters to name = "Window", space_type ='EMPTY', region_type ='WINDOW'
    so our hotkey works in all editor windows
  • then we assign our shortcuts to the operation class
  • we can set a default value to our custom properties that defined as class member using bpy.props
  • we save this hotkeys so we can remove them in unregister function

to make things clear in unregister function we remove our hotkeys

you can see completed script here (code could have some clean ups)

bl_info = {
    "name": "Better_Scroll_Time",
    "blender": (2, 80, 0),
    "category": "Object",
}
#---------------------------------------add-on-info------------------------------------#


import bpy
from bpy.props import *
import addon_utils


class ScrollWheelTime(bpy.types.Operator):
    """Sets the time in range"""      # Use this as a tooltip for menu items and buttons.
    bl_idname = "object.scroll"        # Unique identifier for buttons and menu items to reference.
    bl_label = "Better Time Scroll Wheel"         # Display name in the interface.
    bl_options = {'REGISTER', 'UNDO'}  # Enable undo for the operator.
    direction: IntProperty()
    
    def execute(self, context):        # execute() is called when running the operator.    
        # logic
        scn = context.scene 
        current_frame = scn.frame_current
        current_frame+=self.direction
        scn.frame_set(current_frame)
           
        if not scn.frame_start <= current_frame <= scn.frame_end:
            scn.frame_set(scn.frame_start if self.direction>=1 else scn.frame_end)

        return {'FINISHED'}            # Lets Blender know the operator finished successfully.


addon_keymaps = []


def register():      
    bpy.utils.register_class(ScrollWheelTime)
    # Add the hotkey
    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon
    if kc:
        km = wm.keyconfigs.addon.keymaps.new(name = "Window",space_type='EMPTY', region_type='WINDOW')
        km_up = km.keymap_items.new(ScrollWheelTime.bl_idname, type='WHEELUPMOUSE', value='PRESS', alt=True)
        km_down = km.keymap_items.new(ScrollWheelTime.bl_idname, type='WHEELDOWNMOUSE', value='PRESS', alt=True)
        
        km_up.properties.direction = -1     # setting the default property value for wheel up
        km_down.properties.direction = +1    # setting the default property value for wheel down
        
        addon_keymaps.append((km, km_up))
        addon_keymaps.append((km, km_down))
    
    print("Installed Better Scroll Time !")

def unregister():
    bpy.utils.unregister_class(ScrollWheelUpTime)
    
     # Remove the hotkey
    for km, k in addon_keymaps:
        km.keymap_items.remove(k)
    addon_keymaps.clear()



# This allows you to run the script directly from Blender's Text editor
# to test the add-on without having to install it.
if __name__ == "__main__":
    register()
$\endgroup$
12
  • 2
    $\begingroup$ context is already passed to the operator methods so you can replace bpy.context.* by context.* for all calls/properties and when declaring a variable use it, see: pasteall.org/oUiT/raw Also consider that this is no regular forum and link-only answers are discouraged, if the link goes down so does the answer hence the downvote I guess. $\endgroup$
    – brockmann
    Sep 16 at 8:27
  • $\begingroup$ @brockmann thanks for the tip , I'm new to blender scripting, so should I delete my answer and for example add the link to a comment or no link at all? $\endgroup$
    – mma78
    Sep 16 at 8:37
  • 2
    $\begingroup$ No problem. I'd suggest add a complete explanation what it does, why this is helpful at all and add your code to the answer, see: blender.stackexchange.com/help/how-to-answer Your question isn't clear enough too, no wonder batFINGER's answer is a bit off (IMHO). Also consider using a frame_handler and limit the hotkey to the timeline area. $\endgroup$
    – brockmann
    Sep 16 at 8:55
  • $\begingroup$ thank you . I'll try to make myself more clear next time $\endgroup$
    – mma78
    Sep 16 at 9:04
  • 1
    $\begingroup$ One scrubbing operator going backwards or forwards depending on a prop. If the frame goes past end return to start and continue going forwards , if it goes pre start go to end and continue going backwards. $\endgroup$
    – batFINGER
    Sep 16 at 12:34

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.