0
$\begingroup$

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

Anyone with a hint for me?

Many thanks!

$\endgroup$
1
$\begingroup$

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

enter image description here

$\endgroup$
  • $\begingroup$ Sorry I didn't make clear enough that i wanted to do this via script ... $\endgroup$ – 32Smooth Dec 23 '18 at 13:56
  • $\begingroup$ 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. $\endgroup$ – ElliotThomas Dec 23 '18 at 14:05
0
$\begingroup$

Script version of @ElliotThomas answer

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.

$\endgroup$
  • $\begingroup$ merci (again) batFINGER, works like a charm! $\endgroup$ – 32Smooth Dec 23 '18 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.