3
$\begingroup$

in blend file I have local material called "aluminium". Then I link material called "aluminium" from from different blend file. How can I regonize these two? When I print:

for mat in bpy.data.materials:
        print(mat.name)

It prints "aluminium" twice. When hovering over these in outliner, it shows no python tooltip. Thanks

$\endgroup$
7
$\begingroup$

Look at library property

For two ID objects of same type to have same name will be from different linked libraries

>>> for m in D.materials:
...     m.name, m.library
...     
('Material', None)
('Material', bpy.data.libraries['aubio_tests.blend'])

Can use the library as an extra key

>>> D.materials["Material", None]
bpy.data.materials['Material']
$\endgroup$
1
5
$\begingroup$

You can also use .name_full to differentiate:

>>> print(*[m.name_full for m in D.materials], sep="\n")
Dots Stroke
Material

>>> with D.libraries.load("E:/pixarletter.blend", link=True) as (f, imported):
...     imported.materials = ["Material"]
...     
>>> print(*[m.name_full for m in D.materials], sep="\n")
Dots Stroke
Material
Material [pixarletter.blend]
$\endgroup$
1
  • $\begingroup$ Thanks, thats also helpful to know! $\endgroup$ Sep 17 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.