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?
#OPERATOR WILL RUN WHEN "S" IS PRESSED
import bpy
#Using this in case I want to add more modes later
pivot_modes = ['MEDIAN_POINT', 'INDIVIDUAL_ORIGINS']
i = 0
#IF SCALE IS ALREADY ACTIVE:
#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]
#ELSE:
#Make sure we always start with Mediant Point Mode
#bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
#bpy.ops.transform.resize('INVOKE_DEFAULT')
Edit 1
I found out I can do this:
#If tool is already running
if bpy.ops.transform.resize('INVOKE_DEFAULT'):
#Toggle Pivot Modes
else:
#Turn it on
bpy.ops.transform.resize('INVOKE_DEFAULT')
... 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.