# API / Script - Remove all selected vertices from all Vertex-Groups

How can I remove all selected vertices from all existing vertex groups via script?

Anyone with a hint for me?

Many thanks!

These two scripts have to be run in edit mode.

To remove all selected verts from all vertex groups

import bpy
context = bpy.context
ob = context.edit_object

bpy.ops.object.vertex_group_remove_from(use_all_groups=True)


Alternatively can iterate through vertex groups and use the operator on the active group. This example does as above, can be adjusted to skip certain groups.

import bpy
context = bpy.context
ob = context.edit_object

avg = ob.vertex_groups.active
for vg in ob.vertex_groups:
ob.vertex_groups.active = vg
bpy.ops.object.vertex_group_remove_from()
ob.vertex_groups.active = avg


Can also use the api method vg.remove(), for example: to remove verts with indices 0, 1 and 11 from group "Group"

C.object.vertex_groups["Group"].remove([0, 1, 11])


this has to be run in object mode, or will throw an error.

• merci (again) batFINGER, works like a charm! Dec 23 '18 at 15:42

Select the vertex group from which you want to remove the selected vertices, and press the "Remove" button below the list of vertex groups.

• Sorry I didn't make clear enough that i wanted to do this via script ... Dec 23 '18 at 13:56
• Oh, okay. I'm not great with scripting, but if you hover the "Remove" button, then it will tell you the command that it runs. You could try just copying that command. It seems like your script will just have to select the vertex first and then remove it by inputting the name of the group you want to remove the vertex from. Dec 23 '18 at 14:05