4
$\begingroup$

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)
bpy.ops.ed.undo_push()

# this undo does nothing ...
bpy.ops.ed.undo()

# 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?

$\endgroup$
2

0

You must log in to answer this question.

Browse other questions tagged .