How do I create a undo point?

Or whatever the correct term is. I have a script which creates a bunch of buttons. I press a button which does something. But then I realize that it didn’t do what I wanted, so I undo with Ctrl-Z. Now I would expect Blender to return to the state just before I pressed the button, but in fact it returns to some earlier point. How do I make Blender do what I expect?

I suspect that when I hit Ctrl-Z, Blender pops the stack until it encounters an undo point, i.e. some data structure describing the saved state. My problem would be solved if I could insert such an undo point at the beginning of the execute function in the button operator. How to?

in the operator class definition:
bl_options = {‘UNDO’}

that should do the trick

Thanks a lot. Exactly what I needed :slight_smile: