How can I access the color_attribute
stored for each vertex and store it in an array using Python in Blender 3.4? Using vertex_colors
does no longer work (it gives an error that no vertex_colors are stored). In the Blender API it points to using color_attributes instead. How can I access the rgb values stored for each vertex and store them in an array?
1 Answer
This is through
o.data.color_attributes['Color']
where 'Color' is the name of your color attribute.
From that, you have
o.data.color_attributes['Color'].domain
which can be either 'CORNER' or 'POINT' (respectively 'per face vertex color' or 'per vertex color').
Continuing
o.data.color_attributes['Color'].data[XXX].color[YYY]
where XXX
is the vertex (or the face corner, ie per face) and YYY
is the color component (rgb, etc.).
All this is new... not sure to be able to add more details about that...