I have a script in which I read an FBX File in and replace the input material with a Blender material. The old FBX material remains in the scene tough until the file is closed. I have the name of the old material but I can't find a way to remove it from the file right after the conversion. In the Blender UI, in the Object Lister -> Blender File section I can delete any material immediately out of the file. (Unfortunately the Information Window doesn't show any meaningful code to this operation.) Is there a way to do the same from within Python?
1 Answer
$\begingroup$
$\endgroup$
1
Just get your material, for instance
m = bpy.data.materials['Material.001']
Then remove it
bpy.data.materials.remove(m)
You can also check if m.users
is 0 to be sure the material is not in use somewhere.