Is there an easy way to remove all weight painting influence for a particular bone?
In other words, I would like to select a bone for weight painting and, instead of using a brush to subtract from the existing weight painting, I want to either run a script, press a keyboard shortcut, or choose some sort of menu option that will automatically subtract all weight painting influence for a bone. That way, I can start re-painting the weight and there won’t be any stray, previously-painted vertices that I happened to have missed.
With automatic weighting it will have created vertex groups. Find the vertex group for the bone you’re working on, select, it, then remove. No script required.
Thanks for the reply, @Ryan_Bailey. I’m aware that I can do that, but I’d like to keep the vertex group.
Unless…would it make sense to write a script that would look at the currently-selected bone, delete the associated vertex group (I’m using Rigify, so the vertex group always has the same name as the bone) and then create the vertex group again?
Thanks everybody for the suggestions, but I ended up writing a script that I can call with one click when I’m in weight painting mode:
def get_rig_name():
if bpy.context.mode == 'PAINT_WEIGHT':
for obj in bpy.context.selected_objects:
if obj.type == 'MESH':
for modifier in obj.modifiers:
if modifier.type == 'ARMATURE':
return modifier.object.name
return bpy.context.object.data.name
if bpy.context.active_object.mode == 'WEIGHT_PAINT':
rig_name = get_rig_name()
active_bone_name = bpy.data.objects[rig_name].data.bones.active.name
active_object_name = bpy.context.active_object.name
# We can always assume that a rigged bone has a vertex group with the same name.
obj = bpy.data.objects.get(active_object_name)
source_group = None
for i in range(0, len(obj.vertex_groups)):
source_group = obj.vertex_groups[i]
if source_group.name == active_bone_name:
# Now access the vertices that are assigned to this group
mesh = obj.data
for vert in mesh.vertices:
for vertGroup in vert.groups:
if vertGroup.group == i:
vertGroup.weight = 0
I haven’t thoroughly road tested this yet, but it appears to work as expected.
for anyone coming across this question in the future, I found an easier way to do it:
set the vertices weight to 100% to any bone.
With Vertex Selection enabled and all of the vertices selected (you can enable it by pressing V while weight mode on and pressing A) go to the Weights menu and select Normalize All.
All other bones weights have been removed from the selected vertices, so now, if you remove the bone influence on this vertices, no bone will have influence in this selected vertices.