I created my first Blender operator: If the user selects 1 or more objects, and presses a button, a Python script will replace all the selected objects with cubes of the same size & location. The function first iterates through the objects and saves their data in an array and then deletes them, then it uses that array to create corresponding cubes. Anyway, if I press CTRL
+Z
it usually crashes Blender, since it can't always undo everything.
Is there a way to control what happens when I (or any user) presses CTRL
+Z
immediately after triggering the custom operator? (In my case, I would want to save all the objects I deleted, and then re-add them). Or even prevent Blender from trying to undo that action?
bpy.app.handlers.undo_post
. Blender may crash when you access a invalid pointer. For example:cube = bpy.context.object
>undo
>print(cube.name)
$\endgroup$