Undo Python Script is not working

The description here seems very clearly, but my test code is not working.
The undo entry “My Transaction Test” is in the Undo-History, but it is not undoing the translation.
Anyone can help?

import unreal
actors = unreal.EditorLevelLibrary.get_selected_level_actors() 
location = actors[0].get_actor_location()
with unreal.ScopedEditorTransaction("My Transaction Test") as trans:
	location.z += 28 
	actors[0].set_actor_location(location, False, True)

Maybe I have to explicit set the enter and exit points of the commands to undo?

The enter and exit are magic methods that are called when you use the with command so that wouldn’t be it.

Try using attributes accessible with set_editor_property instead. Something along the lines of:

actors[0].set_editor_property('actor_location', location)

I believe the undo stack might expect all the bells and whistles that come with the ui commands and set_editor_property/get_editor_property seem to hook into that, as opposed to accessing a property/function directly.