Linked_libraries - circular-dependencies

It is known limitation:
https://docs.blender.org/manual/en/latest/files/linked_libraries.html#circular-dependencies

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.

This is a known limitation of the old system. The new asset management system and static overrides won’t have the same limitations as the old system. So I think you should look at the work being done on the id_remap branch which has been working on a very similar problem and see if you can bend the ear of one of the developers working on it. I can’t find a specific page for user feedback, but I think Bastien Montagne is in charge of that feature.