removing materials from with script?

Hello,

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:

ob.setMaterials([])

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:

ob.setMaterials([your_material])

where your_material should be previously defined.

Regards,

Look at the examples for 2.54 see http://blenderartists.org/forum/showthread.php?t=193908&page=3

(the zip file! on page 3)