# How do I get the name or identifier of my newly created mesh from an operator

For example, I can run:

retCode = bpy.ops.mesh.primitive_cube_add().


It doesnt return any kind of identifier, just a code (e.g. "FINISHED", if it finished correctly).

When I make my own operator, I can set programmatically what name it should have, and put that into an input argument to the operator. But this still does not solve the problem, because Blender renames meshes with the .XXX logic when names collide.

I would have expected an interface of the kind:

retCode,AssignedName = bpy.ops.mesh.primitive_cube_add(Name, lots of other args)


What am I missing?

• Short answer is no: blender.stackexchange.com/a/18878/31447 Doesn't matter to much, because the recommended way is to use low level calls anyway: blender.stackexchange.com/questions/61879/… – brockmann Dec 14 '20 at 13:13
• Sigh. Blender uses the operator context paradigm. Changes made by the operator are reflected in the context. The name of a new primitive object would be context.object.name directly after running the operator successfully. (It is expected of operators that create objects to set the new object as both active and selected,) What would be your expectation of the return codes for bpy.ops.object.delete() or show splash screen? – batFINGER Dec 14 '20 at 16:22
• blender.stackexchange.com/questions/45101/… – batFINGER Dec 14 '20 at 16:27
• Thanks @batFINGER. Clear answer, and great link to the connected question. Must be tiring with so many new users interested in this stuff :) – Stefan Karlsson Dec 15 '20 at 13:57
• Apologies , was getting flak elsewhere.. it's to late to "de-sigh" comment above. – batFINGER Dec 15 '20 at 14:02