If you press "S" you activate the scale tool, but I'm trying to create a script where if you press "S" again while the tool is already active... you start to cycle between pivot point modes (median and individual specifically). It's similar to pressing the G key; press it once and you get the Move operator, press it again and it switches to Slide Move.

What command can I use to check if Scale is already running and ONLY THEN switch pivot modes?

I know it's easier to just do the cycling with a separate hotkey, but the point is to re-use the "S" key to both activate the tool and then start switching pivot modes if you keep tapping it.

My script already switches between two Pivot Modes, but I'm missing the "IF SCALE IS RUNNING" check. How can I go about doing that?


import bpy

#Using this in case I want to add more modes later
i = 0


#Store the original Pivot Point
pivot_point = bpy.context.tool_settings.transform_pivot_point[:]

#Change Pivot Modes
if pivot_point == pivot_modes[i]:
    bpy.context.tool_settings.transform_pivot_point = pivot_modes[i+1]   

elif pivot_point == pivot_modes[i+1]:
    bpy.context.tool_settings.transform_pivot_point = pivot_modes[i]


    #Make sure we always start with Mediant Point Mode
    #bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT'


Edit 1

I found out I can do this:

#If tool is already running
if bpy.ops.transform.resize('INVOKE_DEFAULT'):
    #Toggle Pivot Modes
    #Turn it on

... which I feel is a step forward but doesn't work because the IF statement also activates the Scale operator, so it's always going to be True.

Plus, the script doesn't seem to run again while the Scale operator is active so there's a deeper issue I haven't solved.


1 Answer 1


I found the answer in a different post which goes into more detail on how to get it to work.

I don't know if this is allowed but I will link to the original post for a more detailed answer:

Link: How to define double shortcut like GG

Here is the code I used. The explanation on how to set up the keymap so this works is in the post I linked. Once everything is set up, I can tap the S key multiple times, first to activate the scale operator and any subsequent presses toggle between two Pivot Modes I specified.

import bpy
from bpy.props import IntProperty, FloatProperty

class ARC_CustomScale(bpy.types.Operator):
    """Allow SS with the Scale operator, similar to pressing GG to toggle functionality
       of the move tool while the operator is still active"""

    bl_idname = "arc.scale"
    bl_label = "Scale (ARC)"
    bl_options = {'REGISTER', 'UNDO'}


    def modal(self, context, event):
        self.count +=1
        if self.count ==1:
            bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
            print("First Press")

        elif event.type == 'S':
            bpy.context.tool_settings.transform_pivot_point = 'INDIVIDUAL_ORIGINS'           
            bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
            print("Second Press")
            self.count = 0
            #return {'CANCELLED'}

        elif event.type == 'LEFTMOUSE':
            return {'FINISHED'}

        elif event.type in {'RIGHTMOUSE', 'ESC'}:
            return {'CANCELLED'}

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        if context.object:

            return {'RUNNING_MODAL'}
            self.report({'WARNING'}, "No active object, could not finish")
            return {'CANCELLED'}

def register():

def unregister():

if __name__ == "__main__":
  • $\begingroup$ This is really cool. How might you use it to repeat the same hotkey? I'm looking to have 3 operators with the same hotkey. Press it once, activates the 1st operator. Again, 2nd operator. 3rd press is the 3rd operator and 4th press goes back to the 1st operator. Any ideas? I can kind of get it to work, but I'm confused about the count/self.count numbering system. $\endgroup$
    – Increality
    Commented Feb 18, 2021 at 2:45

You must log in to answer this question.

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