I want to append a material from another blend file, but I have problems to get the appended materail:

#This works fine
with bpy.data.libraries.load(self.blendpath, link=False) as (data_from, data_to):
            data_to.materials = ["myTestMaterial"]
#This is the problem maker
mat = bpy.data.materials.get("myTestMaterial")

The problem is that the new material is named "myTestMaterial001" after I run the script for the secound time, is there a way to get the material object directly?


1 Answer 1


You did, but blender renamed it because the old imported data was still in this file, even if not used. You can get rid of unused data blocks in File -> External Data -> Clean Up -> Purge, then try re-appending the material.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .