# How can i append a material from a blend file using python script

I wan't a script that could append a particular material only from a particular blend file so that i can just run the script and the material is there

## 1 Answer

This links a number of named materials from materiallibrary.blend

import bpy
# Load materials
bpy.ops.wm.link(filepath="materiallibrary.blend/Material/LL_WireTrans", directory="materiallibrary.blend/Material/", filename="LL_WireTrans", files=[{"name":"LL_Clay", "name":"LL_Clay"}, {"name":"LL_Glass", "name":"LL_Glass"}, {"name":"LL_WireHold", "name":"LL_WireHold"}, {"name":"LL_WireTrans", "name":"LL_WireTrans"}], relative_path=True)


I did not write the above, Blender created it for me. Run blender.exe --debug-all and manually link your required materials, then in the console will be the python code generated, similar to the above.

Because of the --debug-all you will will also get a ton of other stuff that you will need to sort through.

Link to the project I use this in Camera-track-endevour