I have noticed a weird behaviour while working on a operator.
As Im not sure if its a bug or not I thought i just ask here first
Now what I have trouble with is that operator execute is behaving inconsistent between object and edit mode.
But the snipped should suffice:
def invoke(self, context, event): obj = bpy.data.objects.new( "empty", None ) context.scene.collection.objects.link(obj) self.obj_name = obj.name def execute(self, context): obj = context.scene.objects[self.obj_name]
The object lookup in execute will fail in object mode - I guess the undo stack just reverts it so that the empy does not exist anymore. This is fine and understandable, but if you run the same thing in edit mode it does just ‘work’ - the empty is still alive and will be found.
Is this intended to work like this or expected behaviour? Would be nice if anyone can shed some light onto this…
(after a quick test this seems also to be the case in 2.79)