Taking a cue from this question, I'm testing to make a one-color fill to a vertex_colors. Works fine, but is very slow on meshes with many polygons.
ob = context.object color = (0,0,0,0) vertex_color = ob.data.vertex_colors['My Vertex color'] i = 0 for p in ob.data.polygons: for idx in p.loop_indices: vertex_color.data[i].color = (color) i += 1
I also found an operator,
bpy.ops.paint.vertex_color_set() (It seems to be twice as fast)
but I don't really like the idea, plus it's an operator with no input apparently
Is there any blender Api that do this directly?
After a good answer:
The code above is code that doesn't make sense in this case. My tests moved to this method (Not very fast):
for d in vertex_color.data[:]: #Slow method d.color = (1,0,0,1)
In any case, given @batFINGER answer, and @lemon help, the code is now 4 times and more, faster than before.