Material – colored faces


a In the last station we applied the material to the hole object. Now we select a few faces to color only parts of the object surface.


  1. Create a cylinder and change the color of the top and bottom base.

  2. Create a chessboard like in this image:

  3. Create an set of tokens for the game draughts (or checkers) an the board.
    Louis-Léopold Boilly (1761–1845)
    Painting of a family game of checkers
    (»jeu des dames«)

A colored cube

To be able to color of one or more faces, select them. At first the script:

Name: ''
Blender: 2.69
Group: 'Material'
Tooltip: 'Colored faces'
import bpy

red ='Red')
blue ='Blue')
yellow ='Yellow')

def setColor(obj, material, color):
    material.diffuse_color = color
    material.specular_hardness = 200

def colored_cube():
    """ A three colored cube """

    ob = bpy.context.object = 'three'

    setColor(ob, red, (1, 0, 0))
    setColor(ob, yellow, (1, 1, 0))
    setColor(ob, blue, (0, 0, 1))

    # apply the colors
    for face in
        face.material_index = face.index % 3

if __name__ == '__main__':

Name the colors

Every color should have a name. This is the first Step.

red ='Red')
blue ='Blue')
yellow ='Yellow')

Add the materials

This is little bit tricky, to add a color for each face. Step by step:

  • All faces of an object (a cube has six) are saved in a list of polygons.
  • In a for loop wie iterate over this list.
  • The index number from the list is divided by three with the modulo operator. So we get three possible results 0, 1 or 2.
  • Each number is connected with a color.
  • Finally the color number is assigned to the material index, because materials are also managed with an index.
    # apply the colors
    for face in
        face.material_index = face.index % 3
hint:In old tutorials before 2.68 faces are selected from a list named faces. Now the new list and name is polygons.