Setting materials

Hello blender gurus,

This is a rather silly question, but I just cannot figure it out.

I’m trying to create a polygon mesh consisting of lots of polygons using python. I’d like to be able to assign a seperate material to each polyon.
Could someone please tell me how to do this?

The blender python api seems a bit confusing, the Mesh class function
addMaterial seems to have been disabled, and the Face class only accepts
the INDEX of the material from the Mesh object it belongs to.

Thanks a lot.


First, a Mesh can have only 16 different materials

Second, Assigning a material to a mesh is a buggy thing (to be optimistic) Blender API never developed well in that direction. With old API it was impossible with 2.25 API was a ‘working on’ feature, that’s why doc is confusing.



Thanks a lot for replying.

So, is there a “global material list” thing in blender? It seems that you can create unlimited number of materials when you just use the blender gui to
do the modelling.

As far as the material part of the python API is concerned, is there any
difference between 2.25 and 2.26?

Is 2.27 likely to fix all the missing bits of the python API?

Thanks a lot.