Script from this answer encodes polygons ID to vertex colors:
import bpy
obj = bpy.context.object
obj_data = obj.data
group_name = 'face_ID'
#check for existing group with the same name
if None == obj_data.vertex_colors.get(group_name):
obj_data.vertex_colors.new(name=group_name)
color_map = obj_data.vertex_colors[group_name]
#get faces' number
count = len(obj_data.polygons)
for poly in obj_data.polygons:
ID = poly.index / count #for normalized results
color = (ID, ID, ID)
for loop_ind in poly.loop_indices:
color_map.data[loop_ind].color = color
Can this be done with vertex indices as well?
I've tried to change poly
to vert
and obviously script doesn't work.