Blender 2.66 python

Hi,

I want to be able to create a UV image from within python. I want to be able to control the color values of each face of an object, and be able to save each face color value as a uv image texture.

One possibility I’ve found is to use vertex colors. By editing the vertex color value using:

bpy.context.active_object.data.vertex_colors[0].data[0].color = Color((0,0,0))

Then baking the vertex colors to the UV image. However, how do I go from the index number of a vertex to the specific vertex color data “vertex_colors[0].data[X]”

Is there another way to edit UV images from within python? Is there a way to edit the values of a UV image texture from blender? Can python access the UV coordinates of faces in the UV image?

Much appreciated!
Jesse

Im not sure what you want todo.
I guess you want to save the vertex_color_map as an image using UV_Map coordinates.
Heres some python data.

# vertex_colors
>>> bpy.data.meshes['Cube'].vertex_colors['Col'].data[23].color
Color((1.0, 0.9019607901573181, 0.0))

# uv_layers
>>> bpy.data.meshes['Cube'].uv_layers['UVMap'].data[23].uv
Vector((0.6687497496604919, 0.5000002384185791))

# images
>>> bpy.data.images['cube.PNG'].pixels[400]
0.4705882668495178
me = bpy.data.meshes.get('Cube')
if me is not None:
    for li in me.polygons.active.loop_indices:
        me.vertex_colors.active.data[li].color = (1,0,0)