I did the following steps to create a new material and link it to the object:
Select an object.
In Button window (at bottom) select 'Shading' (a gray ball) and then 'Material buttons' (red ball)
In 'Link and pipeline', press 'Add new'.
Edit material color ('Col').
I want to change the color randomly using this script:
from random import random
from Blender import *
scn = Blender.Scene.GetCurrent()
ob = scn.objects.active
m = ob.getData(mesh=True)
if(len(m.materials) < 1):
mat = Material.New('newMat')
m.materials += [mat] m.materials.rgbCol = [random(), random(), random()]
Why doesn't the color of the object change?
Because, random() returns a number between 0 and 1. I expect rgbcol must be between 0 and 255.
m.materials += [mat]m.materials.rgbCol(random()*255, random()*255, random()*255)
it is changing the color, (unless it has some other problem) but the effect is too small to be noticable.