I'm trying to get what operator had been called before the current operator and make some logic based on that. Is this information accessible?


1 Answer 1


Blender records all operator calls in WindowManager.operators list: https://docs.blender.org/api/current/bpy.types.WindowManager.html#bpy.types.WindowManager.operators

import bpy

ops = bpy.context.window_manager.operators
# <bpy_collection[46], WindowManager.operators>

To get the second-to-last operator name in the list, you can use negative indices and Operator.name to get the name: https://docs.blender.org/api/current/bpy.types.Operator.html#bpy.types.Operator.name

print(ops[-1].name) # last operator name
print(ops[-2].name) # second to last operator name

# Join
# Move

... same for Operator.bl_idname: https://docs.blender.org/api/current/bpy.types.Operator.html#bpy.types.Operator.bl_idname

print(ops[-1].bl_idname) # last operator bl_idname
print(ops[-2].bl_idname) # second to last operator bl_idname

# OBJECT_OT_join
# TRANSFORM_OT_translate

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.