Is there some way to change mesh attributes in EDIT with foreach_set and foreach_get (the same way it works in OBJECT mode) besides going to bmesh? I’ve tried and it gives me an error -RuntimeError: internal error setting the array
.
What I’ve also noticed in EDIT mode all attributes length becomes 0 for some reason and I guess this is what causes an error.
Easy way to reproduce - create default blender scene, select cube and run:
from mathutils import Vector
from itertools import chain
me = bpy.context.object.data
if 'test' not in me.color_attributes:
me.color_attributes.new('test', type='FLOAT_COLOR', domain='POINT')
me.update()
attr = me.color_attributes['test']
out = [None] * 4 * 8
attr.data.foreach_get('color', out)
print(out)
new_values = [Vector((1.0, 0.0, 0.0, 0.0)) for i in range(8)]
new_values = list(chain(*new_values))
attr.data.foreach_set('color', new_values)
attr.data.foreach_get('color', out)
print(out)
me.update()