# How to get the color of a vertex group with python?

Is it possible to get the color of a vertex group that is coloured with dynamic paint? I have a mesh of tree which was created from particle instance and then applied. Then I joined all of that to create a single mesh. Then dynamic paint was used to draw a color on that.

The complex part is that I need to get the color of the vertex group which was named leaf-1.

I proceeded with dynamic paint for coloring the mesh and that is a brilliant tool. Now I need to export the color values of that vertex. I thought the dynamic paint values are stored in the dp_paintmap vertex color. But that values are full of (1.0,1.0,1.0,1.0). I have been searching for this and found a similar question. blender.stackexchange.com/questions/123261/getting-color-values-produced-by-dynamic-paint Please help me. Where is this data stored?

## 1 Answer

Finally the answer is found. https://developer.blender.org/T82451

Thanks to Phillip You need to read this from the evaluated object, see


import bpy

ob = bpy.context.object

depsgraph = bpy.context.evaluated_depsgraph_get()
object_eval = ob.evaluated_get(depsgraph)

#vertex colors are in fact stored per loop-vertex -&gt; MeshLoopColorLayer
if ob.type == 'MESH':

#how many loops do we have ?
loops = len(object_eval.data.loops)
verts = len(object_eval.data.vertices)
print("--------------------------------------------")
#go through each vertex color layer
for vcol in object_eval.data.vertex_colors:
# look into each loop's vertex ? (need to filter out double entries)
visit = verts * [False]
colors = {}

for l in range(loops):
v = object_eval.data.loops[l].vertex_index
c = vcol.data[l].color
print("Vertex {0} has Color {1}".format(v, (vcol.data[l].color[0],vcol.data[l].color[1],vcol.data[l].color[2])))
if not visit[v]:
colors[v] = c
visit[v] = True

sorted(colors)
print("Vertex-Colors of Layer:", vcol.name)
#print(colors)
#        for v, c in colors.items():
#            print("Vertex {0} has Color {1}".format(v, (c.r, c.g, c.b)))
#
print("")


The magic of depsgraph