I have an armature with a lot of bones that each have some weight paint on a part part of the body, I want to delete pretty much all the bones and transfer their weight to their parent bone. I cant use vertex weight mix cuz it would take a long time and would be complicated since there are a lot of bones


1 Answer 1


Python script

In the lines 3-5 specify your armature's name, the source bone to remove (it will be removed together with all of its children - and their children and so on, recursively). The weights will be transferred (by addition, which Blender automatically clamps in 0..1 range so it won't add up to more than 1) to the target bone.

import bpy

arm = bpy.data.armatures['Skeleton']
source = arm.bones['upperFaceRig']
target = arm.bones['head']

def transfer_weights(source, target, obj):
    source_group = obj.vertex_groups.get(source.name)
    if source_group is None:
    source_i = source_group.index
    target_group = obj.vertex_groups.get(target.name)
    if target_group is None:
        target_group = obj.vertex_groups.new(name=target.name)
    for v in obj.data.vertices:
        for g in v.groups:
            if g.group == source_i:
                target_group.add((v.index,), g.weight, 'ADD')

def remove_bone(source, target):
    for o in bpy.data.objects:
        transfer_weights(source, target, o)
    edit_bone = arm.edit_bones.get(source.name)

def main():
    for bone in source.children_recursive:
        remove_bone(bone, target)
    remove_bone(source, target)


Based on Exporting weight and bone elements to a text file

  • $\begingroup$ I'm getting this error with this script: line 32, in remove_bone TypeError: ArmatureEditBones.remove(): error with argument 1, "bone" - Function.bone does not support a 'None' assignment EditBone type $\endgroup$
    – 0x_Anakin
    Commented Apr 11, 2023 at 14:07
  • $\begingroup$ @0x_Anakin can you upload a file with the problem? $\endgroup$ Commented Apr 11, 2023 at 14:12
  • $\begingroup$ It's a genesis 8 female, I just replace Skeleton with Genesis 8 Female which is the armature name the other 2 are the same $\endgroup$
    – 0x_Anakin
    Commented Apr 11, 2023 at 14:24

You must log in to answer this question.

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