0
$\begingroup$

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?

$\endgroup$

1 Answer 1

0
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Oh, that was simple. Thanks! $\endgroup$
    – Steve
    Commented Mar 22, 2023 at 14:27

You must log in to answer this question.

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