I have a python script that sets vertex colors per vertex (reading the data from lists) which worked in blender3.3. I'd like to use that script in blender 3.5 (simulations branch) but it throws an error message, ( that it cannot find the color attributes name in the vertex' loops names )
I cant find any sample code of how to write the list of rgba values into a specified mesh's color attribute.
Any link or hint to sample code ? set color attributes via foreach_set() sample or smth like that? thanks for your time.
Previously used code, that wont work in blender 3.5, since it doesn't use layers to store color_attributes, i guess:
bpy.ops.object.mode_set(mode='OBJECT')
names=[l.name for l in obj.data.attributes]
if colname not in names:
bpy.ops.geometry.color_attribute_add(name=colname)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
bm = bmesh.from_edit_mesh(obj.data)
for v in bm.verts:
for l in v.link_loops:
vcol=bm.loops.layers.color[colname]
l[vcol] = [coldict[v.index],coldict[v.index],coldict[v.index], 1.0 ]