Add-on bypass 'undo' history?


My question is about Blender’s ‘undo’ history, in relation to a custom UI Panel.
I am using the current Blender version 2.83.1 and have written an add-on which uses a Panel, some Properties and a few {INTERNAL} Operators without {UNDO}.

Each time I change the value of a property, on the Panel display, Blender’s history is updated with that last action. I don’t mind Blender doing his stuff but this ‘action-undo’ recording thing leads to inconsistencies. For instance, I have a Operator which clears all items in a list and deletes the corresponding objects. Now, if a user selects the last ‘Undo’, the list is re-populated with the previously removed items but the objects have, of course, vanished. This obviously breaks the logic of my program and it sometimes even crashes Blender.

So, in short, I would like to know if there is a way for an add-on to bypass the ‘undo’ history.

Thank you


Well, after some random googling, I came across a post over at the devtalk forum which indirectly answered my question. Apparently, the ‘undo/redo’ system of Blender cannot be bypassed. Indeed, it is essential that any Operator which makes changes to the scene should include the {‘UNDO’} tag in bl_options. I wonder why this is not mentioned in the API Docs?

Anyway, after adding the UNDO tag to my Operators, the state of my add-on is updated correctly and there are no crashes. So, thank you Brecht!

Here is a link to the post for anyone who might be interested
Addon Operators and Undo Support

1 Like

Thank you so much !!!
It helped me a lot :+1:

You’re welcome! Good of you to let me know

1 Like