TransWikia.com

Connect parent bone tail to child head

Blender Asked by sezanzeb on December 4, 2020

I’d like to connect the tail of a parent bone to the head of a child bone, because it looks more organized.

This is how it currently looks like

how it looks like

This is how it should look like

how it should look like

Since there are a lot of bones involved, I’d like to make this programmatically in python to save time.

I tried to overwrite the .tail property of a bone but it didn’t save it or something. Nothing changed.

One Answer

First, you have to switch to the object mode.

In a python console, enter something like this. Make sure to change the name of the armature to what you have. The .tail property is not what you want to overwrite, it's the tail_local.

for bone in bpy.data.armatures['Armature'].bones:
    if bone.parent is not None:
        bone.parent.tail_local = bone.head_local

Then switch to edit mode to see the effect


If your parents can have multiple children and if you only want to move those tails that have a single children, you can try to use this code snippet:

parent2children = {}

for bone in bpy.data.armatures['Armature'].bones:
    if bone.parent is not None:
        if bone.parent.name in parent2children:
            parent2children[bone.parent.name].append(bone)
        else:
            parent2children[bone.parent.name] = [bone]


for name in parent2children:
    if len(parent2children[name]) == 1:
        parent = bpy.data.armatures['Armature'].bones[name]
        parent.tail_local = parent2children[name][0].head_local

make sure to switch to object mode first here as well

Answered by sezanzeb on December 4, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP