AnswerBun.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!

Related Questions

Why isn’t it filling in when I extrude?

1  Asked on January 31, 2021 by notesalad

   

exporting an file as fbx fails

4  Asked on January 31, 2021 by suzly

   

Blender 2.9 – UV Unwrap not appearing

1  Asked on January 31, 2021 by theodor

   

imported bones locked in rotation

1  Asked on January 31, 2021 by francois-gibon

 

Material transparency issue

0  Asked on January 30, 2021 by pip

 

Walk mode camera “jumps” back when stopped

3  Asked on January 30, 2021 by ganonflake

     

Pose change is not permanent

1  Asked on January 30, 2021 by tmighty

   

Workflow: Baking Before Texturing?

0  Asked on January 27, 2021 by xmthomas

     

How can I change the transform by minimal code?

1  Asked on January 27, 2021 by seyed-morteza-kamali

 

Image texture : how to only sculpt bright areas?

0  Asked on January 26, 2021 by wilcar

   

Align Grease Pencil with Camera Angle

1  Asked on January 25, 2021 by moonmen

   

2.8 How can I draw and fill a closed shape in 2D?

1  Asked on January 24, 2021 by rancher-o

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir