Call an operator from inside a different operator and still show the redo/adjust panel

An artist at my studio requested a custom operator that would essentially be a ‘smart operator’ on a single hotkey that did different things depending on the context. this is easy to do, obviously- the problem is that when you call an operator in this way the redo panel for that operator doesn’t show up. I was hoping there was an INVOKE flag that would tell Blender that this was the operator call that needed the redo panel but I’m not finding anything.

anybody know of a trick to make this happen, or is this guy SOL? And in case you’re wondering- it’s not as simple as just setting a hotkey for different modes, because the contexts we’re checking for are more specific than that, ie) if edges are selected, do this- if faces are selected, do that.

I believe adding True to the operator call will propagate the undo, even when the contextual operator itself doesn’t have {'REGISTER', 'UNDO'}.

True comes after the invocation type argument, and before any operator specific keyword arguments.

Example:


    def execute(self, context):
        if context.mode == "OBJECT":
            return bpy.ops.transform.rotate('INVOKE_DEFAULT', True)
        elif context.mode == "EDIT_MESH":
            return bpy.ops.mesh.primitive_cube_add('INVOKE_DEFAULT', True)
        return {'CANCELLED'}
1 Like

Aha! That worked great as soon as I removed the conflicting bl_options from the switchboard operator. Thanks!

1 Like