After 4.1 when you set name of object A to “Cube” and “Cube” is already present as object B it will rename object A to “Cube.001”.
Prior to 4.1 it would change A → “Cube” and B → “Cube.001”. Which seems more intuitive though it’s a bit bad practive given that it renamed object B though it never asked to do so (atleast explicitly).
Explained here:
Any thought how name-swapping can be allowed after 4.1 using an addon?
Had an idea that it can be possible using bpy.msgbus.subscribe_rna
to object’s (or other IDs) names but it has some problems:
-
need to somehow ensure that there will be a subscription to all objects/IDs. And the only way to do in Python API rn is to ensure it in
depsgraph_update_post
which seems to be overkill - iterating over all IDs at every despgraph update won’t be good for performance. -
even after renaming A → “Cube” callback from
bpy.msgbus.subscribe_rna
gets called already after A name is changed to “Cube.001”. So there is no way to know whether usually actually changed it to “Cube.001” or they intended to rename it to “Cube”. Resolving that again would take storing all previous object names indepsgraph_update_post
…
Alternatively, there could be a button in object’s context menu that would use a different type of renaming that would allow name-swap. The downsides:
-
user would have to use this button only for renaming as renaming by just clicking on object’s name from outliner will result in renaming without name-swap, which is kind of unintuitive but could be good enough
-
won’t work for other IDs (materials, etc) as you typically change their names directly, not through context menus.