Undo not work ಠ╭╮ಠ

Example test code
bl_info = {
	"name": "TOP",
	"author": "IIIFGIII",
	"version": (1, 0),
	"blender": (2, 83, 0),
	"location": "Viev3D > N panel > FG Tools > TOP",
	"description": "Test Operator.",
	"warning": "",
	"wiki_url": "",
	"category": "FG_Tools",
}

import bpy, math

class TOP_PT_Panel(bpy.types.Panel):
	bl_label = 'TOP'
	bl_idname = 'TOP_PT_Panel'
	bl_space_type = 'VIEW_3D'
	bl_region_type = 'UI'
	bl_category = 'FG_Tools'

	def draw(self,context):
		layout = self.layout
		row = layout.row(align=True)

		row.operator('fgt.top', text='', icon='ADD')


class TOP_OT_Test(bpy.types.Operator):
	bl_idname = 'fgt.top'
	bl_label = 'TOP_OT_Test'
	bl_option = {'REGISTER','UNDO'}
	bl_description = 'Test operator.'


	def execute(self,context):
		bpy.ops.transform.rotate(value= math.radians(45.0), orient_axis= 'Z', orient_type= 'GLOBAL')
		return{'FINISHED'}

CTR = [
	TOP_PT_Panel,
	TOP_OT_Test,
	]

def register():
	for cls in CTR:
		bpy.utils.register_class(cls)


def unregister():
	for cls in CTR:
		bpy.utils.unregister_class(cls)

This example is absolutely similar to operator in addon I workking on. Nothing speciall - just custom operator to rotate something with button. {'REGISTER','UNDO'} added but I not able to undo this operator action.

Simplest thing ever but I can’t make it work properly. Tested on 2.83.13/2.93.2/3.0 alpha. Am I just stupid, do I miss something? Googling not help so I ask here.

In info window it look same as ordinary rotation. What I do wrong guys?

when you’re using built-in operators (especially modal operators like transform) you have to manually handle undo ‘snapshots’. for this operator, the best way to do it would be like so:

def execute(self,context):        
        bpy.ops.transform.rotate(value= math.radians(45.0), orient_axis= 'Z', orient_type= 'GLOBAL')
        bpy.ops.ed.undo_push()
        return{'FINISHED'}
1 Like

So it’s like some general rule something? If so why on API page there is no word about this.

Anyway thank you kindly, it work, I’m happy now ))

yeah unfortunately that bit of information might be tribal knowledge that has not found its way into the docs yet. it probably isn’t included because the devs only added it to get around some edge cases (such as this one) and it’s not a fully designed feature yet.