Need help with Macro

Hello everyone. I want to call something after baking texture. So I create a macro:

import bpy
from bpy.types import Operator, Macro

class SomethingAfterBake(Operator):
    bl_idname = "wm.finish"
    bl_label = "Final"

    def execute(self, context):
        print("DONE!")
        return {'FINISHED'}

class MyMacro(Macro):
    bl_idname = "wm.my_macro"
    bl_label = "Macro Sequence"
    
def register():
    bpy.utils.register_class(SomethingAfterBake)
    bpy.utils.register_class(MyMacro)

    MyMacro.define("object.bake")
    MyMacro.define("wm.finish")

if __name__ == "__main__":
    register()

But if I want to call it as bpy.ops.wm.my_macro or put into ui layout, it doesn’t work. How can I call my macro from a script?

1 Like