help with new API

Hi all,

I’m trying to update a script that modify vertexcolors.

With the actual 2.62 API:

vcols = mesh.vertex_colors.active.data
for face in mesh.faces:
vcol = vcols[face.index]
vcol.color1 = myColor1
vcol.color2 = myColor2

With the new 2.63 API:

vcols = mesh.tessface_vertex_colors.active.data
for face in mesh.tessfaces:
vcol = vcols[face.index]
vcol.color1 = myColor1
vcol.color2 = myColor2

This works, but if i change the object mode (edit, object,…)
the colors are lost. It comes back to the previous ones.

How can a apply the changes ?

thanks for your help.
(i hope it’s clear, I’m not good in English)

One of the reasons I heard for changing faces --> tessfaces was that it would make it clear to the user that the edited data would be lost (or that’s what I remember at least, good possibility I’m totally wrong here).

Your best bet would be to look at the newly updated template scripts to see how this stuff is supposed to be used now.

Well,

I tried this with bmesh (this mesh have vertex colors).

me = bpy.context.object.data
bm = bmesh.new()
bm.from_mesh(me)
for face in bm.faces:
for loop in face.loops:
print(loop)

And i get:

<BMLoop(0xae4458b8), index=0, vert=0xb0395180/8, edge=0xae42d4c4/27, face=0xb02c52a0/16>

No color layers.

I dig, i dig , but still nothing:

if i try:

bm = bmesh.new()
bm.from_mesh(mesh)
col=bm.loops.layers.color.active
print(dir(col))
print(type(col))

there’s nothing related to vertexcolors … :frowning:

Do someone know how to modify vertexcolors with the bmesh module ?