# Difference between FINISHED and CANCELLED as return values

What is the difference between

return {'FINISHED'}


and

return {'CANCELLED'}


in an operator?

For example, lets assume I have a simple non modal operator which places a cube in the scene and returns {'CANCELLED'} afterwards. Are there any consequences or further impact? My guess was that the cube would be removed from the scene (like an undo) because of potential errorneous behavior. But it stays there just like everythings works fine

AFAIK it's so that you can check in a script whether an operator executed properly or not, by inspecting its return value. For Blender itself it doesn't matter, but it starts to become relevant when you use one operator from another.

For example:

result = bpy.ops.object.delete()

if result == {'FINISHED'}:  # Can also do: if 'FINISHED' in result:
print ("Successfully deleted object")
else:
print ("Could not delete object")

• I imagined it might have to do with whether an undo entry is generated or not. Is that wrong?
– Zyl
Dec 31, 2021 at 13:04