Redo Last with Macro

Heya, I have a macro that selects all UV’s, applies an average scale and then packs the UV’s:


import bpy
bpy.ops.uv.select_all(action='SELECT')
bpy.ops.uv.average_islands_scale()
bpy.ops.uv.pack_islands(margin=0.02)

I then want to be able to use ‘Redo Last’ on the pack part, is this possible?
With the macro like this the Redo Last works on the operator before the macro.

You need to make an operator and copy paste the lines there. You can then invoke the operator in any way you want including binding it to a hotkey.

Quick copy paste (ud probably want a bit more tuning):



import bpy


class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {'REGISTER', 'UNDO'}


    def execute(self, context):
        bpy.ops.uv.select_all(action='SELECT')
        bpy.ops.uv.average_islands_scale()
        bpy.ops.uv.pack_islands(margin=0.02)
        return {'FINISHED'}


def register():
    bpy.utils.register_class(SimpleOperator)


def unregister():
    bpy.utils.unregister_class(SimpleOperator)


if __name__ == "__main__":
    register()


    # test call
    bpy.ops.object.simple_operator()