0
$\begingroup$

I know that selecting vertices is possible in edit mode. I want to color after selecting a vertex in vertex paint mode. Is that possible?I want to color only the vertex, not the edge or face.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

This does what you want I think. It's not particularly efficient though since it loops through all verts and all loops.

import bpy

ob = bpy.context.active_object
assert ob.type == 'MESH'
assert ob.mode == 'VERTEX_PAINT'

mesh = ob.data

# Get the active vertex color layer
color_data = mesh.vertex_colors.active.data

# Find index of all selected verts
sel_vindexs = set(
    v.index for v in mesh.vertices if v.select
)

# Find all loops (loop = corner of a poly) that touch
# a selected vert and make them to red
for loop in mesh.loops:
    if loop.vertex_index in sel_vindexs:
        color_data[loop.index].color = [1, 0, 0, 1]
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .