How can I remove all selected vertices from all existing vertex groups via script?
Anyone with a hint for me?
Many thanks!
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityHow can I remove all selected vertices from all existing vertex groups via script?
Anyone with a hint for me?
Many thanks!
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.
Select the vertex group from which you want to remove the selected vertices, and press the "Remove" button below the list of vertex groups.