1
$\begingroup$

I would like to add vertices in a vertex group with a weight already set by python.

For example a button that set weight force to the selected vertices to 0.5:

row.operator ("object.vertex_group_assign", text=" 0.5")

$\endgroup$

1 Answer 1

0
$\begingroup$
for v in obj.data.vertices:
    if v.select:
        for g in v.groups:
            if g.group is your_target:
                obj.vertex_groups[g.group].add([v.index], your_weight_value, 'REPLACE')
$\endgroup$
1
  • $\begingroup$ Hi, thanks for the post. This site is not a regular forum, answers should be substantial, stand on their own, and thoroughly explain the solution and required steps. One liners and short tips or code-only posts rarely make for a good answer. If you can, edit your post and provide some more details about the procedure and how it works, perhaps add a few images illustrating some steps and final result. See How to write a good answer?. $\endgroup$ Commented Apr 15 at 14:53

You must log in to answer this question.

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