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$
6
$\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")
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.