# Undo Python Script is not working

**URL:** <https://forums.unrealengine.com/t/undo-python-script-is-not-working/442991>\
**Category:** Editor Scripting\
**Tags:** Python, unreal-engine, bug-report, UE4, question\
**Created:** [February 8, 2019, 5:59pm UTC](https://forums.unrealengine.com/t/undo-python-script-is-not-working/442991 "2019-02-08T17:59:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SebaSopp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SebaSopp](https://forums.unrealengine.com/u/SebaSopp)\
**Post date:** [February 8, 2019, 5:59pm UTC](https://forums.unrealengine.com/t/undo-python-script-is-not-working/442991/1 "2019-02-08T17:59:21Z")

</div>

The description [here](https://docs.unrealengine.com/en-US/Editor/Scripting-and-Automating-the-Editor/Scripting-the-Editor-using-Python#supportingundoandredo) 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?  
[https://api.unrealengine.com/INT/PythonAPI/class/ScopedEditorTransaction.html?highlight=scoped](https://api.unrealengine.com/INT/PythonAPI/class/ScopedEditorTransaction.html?highlight=scoped)

---

<div class="post-metadata">

**Author:** ![NEXUS\_murderturd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NEXUS\_murderturd](https://forums.unrealengine.com/u/NEXUS_murderturd)\
**Post date:** [February 24, 2019, 5:29pm UTC](https://forums.unrealengine.com/t/undo-python-script-is-not-working/442991/2 "2019-02-24T17:29:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Claudio.Alvaro](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/claudio.alvaro/32/618031_2.png) [@Claudio.Alvaro](https://forums.unrealengine.com/u/Claudio.Alvaro)\
**Post date:** [July 11, 2019, 1:44pm UTC](https://forums.unrealengine.com/t/undo-python-script-is-not-working/442991/3 "2019-07-11T13:44:00Z")

</div>

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.
