5
$\begingroup$

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

$\endgroup$

1 Answer 1

7
$\begingroup$

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")
$\endgroup$
1
  • $\begingroup$ I imagined it might have to do with whether an undo entry is generated or not. Is that wrong? $\endgroup$
    – Zyl
    Commented Dec 31, 2021 at 13:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .