removing materials from with script?


Before I write anything more than hello, let me tell you that I’m a total noob at both blender and python (I started using them on Thursday ) so I may not describe everything with correct names :smiley:

Is there any way to delete material (and by delete I mean delete it from the materials list)?
I know this can be done by quiting blender, but since it is in the middle of my script I can’t do that :wink: I import an .obj file, and want to set the material properties, unfortunately when I import the file it already comes with some material (2 of them actually). And it seems I can’t overwrite them. Now what I do is change their properties “manually” in script, but it would be more elegant to delete that imported materials and link the object to my predefined material. Is it possible?

Dont know in 2.5x versions, but in 2.49 this:


would delete ALL materials assigned to the object cause it sets its list to an empty list.

Should you like to assign a material you should put it in a list:


where your_material should be previously defined.


Look at the examples for 2.54 see

(the zip file! on page 3)