I would like to get and set color values numerically (ie. not painting),
There may be add-ons that cater to this, but at present (March 2016)
- Blender doesn't have a (non-Python) way to set the Vertex Colors per selected vertex/vertices. Per face is however, as stated below, not a problem.
There is no built-in interface (yet) to get the rgb value of a selected Vertex. Each vertex can be shared by a number of faces, therefore a vertex doesn't necessarily have one color associated with it. Behind the scenes the Vertex Colors are not stored in the data per vertex but in a Vertex Color layer, which stores vertex colors for each face of the mesh.
Possibly this explains that a bit more clear. There are 9 verts in this subdivided plane, and the middle vertex is used in 4 faces and therefore has 4 different colors associated.
Vertex Color Map
You can set a collection of faces to one colour in vertex paint mode, by selecting them and setting the colour from the colour picker, then shift+K will fill the selection with that colour. You can enter numericals into the Blender colour picker.
You can pick faces with
face selection masking
If you want to do it by script:
# start in object mode
obj = bpy.data.objects["Cube"]
mesh = obj.data
if not mesh.vertex_colors:
let us assume for sake of brevity that there is now
a vertex color map called 'Col'
color_layer = mesh.vertex_colors["Col"]
# or you could avoid using the color_layer name
# color_layer = mesh.vertex_colors.active
i = 0
for poly in mesh.polygons:
for idx in poly.loop_indices:
rgb = [random.random() for i in range(3)]
color_layer.data[i].color = rgb
i += 1
# set to vertex paint mode to see the result
Also a small blogpost about vertex colours here and here, if you are so inclined.
Weight Painting, i'm not sure -- i'll let someone more familiar with that give an answer