It is known limitation:
Lets say I want to import ‘Table’ object from other blend file, with ‘Red’ material which link back to current file (circular dependency). Current file contains actual ‘Red’ material datablock node tree definition.
/# import Table object
with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to):
data_to.objects = [name for name in data_from.objects if name == ‘Table_red’]
There will be warning in console when importing red, material:
#Warning: LIB: Data refers to main .blend file: ‘MARed’ from C:\xxxx\table_red.blend
But ‘Red’ material itself wont be show in data_to.materials list, so python wont even ‘know’ there was missing datablock (with circular dependency) on import. Table will just come with empty material slot.
Why blender wont just check:
- if imported datablock (‘Red’ material) links to current blend file, replace it, with actual data it points to.
- if there is no this data block, then just skip importing red mat, like it does now.
I do not even have chance in my script, to check if incoming datablock links to current file, and if so, replace link with actual datablock.