1
$\begingroup$

Pretty simple question, it's pretty easy to create a new vertex group using bpy.ops.object.vertex_group_add(), but I can't find any way to specify the name of this new group without editing it in the Properties menu. Maybe I'm blind, but it just doesn't seem to be obvious to me.

$\endgroup$

3 Answers 3

5
$\begingroup$

You can use obj.vertex_groups.new(name="mygroup") instead where you can specify the name while creating the group.

if you need to use bpy.ops.object.vertex_group_add() and want to specify the name after that you can also set it as follows : obj.vertex_groups[-1].name="mygroup"

$\endgroup$
0
$\begingroup$

Easier method discovered by a newbie: click on "Weight" (directly beneath, where you would change the default value away from 1.000) and then press tab to scroll through the names of the vertex groups and change them accordingly. I think this is a bug. There's a similar workaround for the name of particle groups in the Active Particle System Index: click in the reusable name slot beneath (above "Emitter"/"Hair" buttons) and then tab through the index.

$\endgroup$
1
  • 1
    $\begingroup$ FYI, this is not a bug. Tab is a standard way to navigate through input field. and the question was about to rename a group using Python. If you want to rename it directly using the gui, without using tab, you can double click on it. $\endgroup$
    – lemon
    Aug 21, 2019 at 8:48
0
$\begingroup$

You only need two lines of code, one to create a vertex group with a specific name and the other to assign the selected vertices to this new group.

import bpy

# your code here

# New Vertex group from selected vertices

bpy.context.object.vertex_groups.new(name='New_Vertex.000')
bpy.ops.object.vertex_group_assign()

here my full post: How do I create a vertex group from selected vertices in edit Mode with Python (Blender 2.8)?

$\endgroup$

You must log in to answer this question.

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