Hello Blender devs,
I’m working, on an addon to transfert data from blend file to blend file and process them afterward.
bpy.ops.wm.link command to tranfert data. But I’m having trouble to understand what’s happening behind the scene regarding name collision.
Indeed in Blender two objects can’t have the same name, and they get renamed automatically. Durring an
append, the same rules is applies : the appended objects got renamed if other objects with the same name already exists in the file, and I didn’t found the way to catch the objects into variable to be able to process them properly.
The workaround that I’ve found was to
link them instead which doesn’t resolve the name conflict yet ( because the data is still hosted in the source blend fileI guess), then store the object in a dict,
make_local() and process them the way I want. But even though, the result is not always predictable, and it look like the objects name are not always updated correctly.
So here are my questions :
- Is there any way to append/ link data with more control than the default command ?
- Is there a doc explaining how object/data auto renaming works in blender ? ( Haven’t found one )
- Is there a way to force data to update after
I’ve made a simple setup to test this behaviour:
- I’ve made simple scene with many objects,
- Duplicate the file
- Linked all object from one scene to the other ( which now contains each data twice : One strored in currend file, and another linked from the ducplicated scene).
- select the linked elements and run this simple script
import bpy selected_objects = bpy.context.selected_objects for o in selected_objects: print('initial_name =', o.name) o.make_local() print('new_name = ', o.name, '\n') print('process_done')
And as you can see, not all object returns another name after
make_local() command is executed. And even the outliner doesn’t refresh after screen execution. It refreshes only when I hover the mouse over the outliner.
initial_name = Cube new_name = Cube.004 initial_name = Cube.001 new_name = Cube.001 initial_name = Cube.002 new_name = Cube.006 initial_name = Cube.003 new_name = Cube.007 initial_name = Lattice new_name = Lattice.001 initial_name = Mball new_name = Mball.002 initial_name = Mball.001 new_name = Mball.001 initial_name = Spot new_name = Spot initial_name = Spot.001 new_name = Spot.001 initial_name = Stroke new_name = Stroke.005 initial_name = Stroke.001 new_name = Stroke.006 initial_name = Stroke.002 new_name = Stroke.007 initial_name = Stroke.003 new_name = Stroke.008 initial_name = Stroke.004 new_name = Stroke.004 initial_name = SurfPatch new_name = SurfPatch.001 process_done