I am trying to undo an operation in a script but the bpy.ops.ed.undo() does not work.
The exactly same sequence of statements run in Python Console works as expected.

A code that demonstrates this behavior is this (run from Text editor):

import bpy

# ... already in Edit mode, selected all

bpy.ops.mesh.remove_doubles(threshold = 0.1)
# the above says "Info: Removed 30 vertices"

# create new undo step (without this it doesn't work in Python Console either)

# this undo does nothing ...

# because this ...
bpy.ops.mesh.remove_doubles(threshold = 0.1)
# says "Info: Removed 0 vertices"

Interestingly enough the pushed undo step is visible in Undo History right before the Run Script step - and it can be undone, of course.

Is there a catch I'm missing here?



You must log in to answer this question.

Browse other questions tagged .