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

Weight Paint only Upward Faces

1  Asked on December 26, 2021 by mistargo

 

Why is there a transparent rectangle behind my object?

1  Asked on December 26, 2021 by rectanglehelp

 

OpenVDB does not show in render?

1  Asked on December 26, 2021 by emir-cetinoglu

         

How to stop smoke from lingering around

0  Asked on December 26, 2021 by samuel-e

   

How to setup the camera into front view?

0  Asked on December 26, 2021 by crazyup90

 

Facing Problem in drawing UI Previews Dynamic EnumProperty

1  Asked on December 26, 2021 by rakesh-choudhary

         

How creating function to aplying image to object python

0  Asked on December 26, 2021 by pronto

     

Scripted expressions editor gives unexpected results

1  Asked on December 26, 2021 by ore-manojlovi

     

Diffuse bake alpha

2  Asked on December 24, 2021 by user3101851

       

Set a modified mesh (with shape keys) as default mesh

1  Asked on December 24, 2021 by mai-sasaki

   

How to switch object in sculpt mode?

4  Asked on December 24, 2021 by davy-li

   

How to Bake High Poly Object Details (Shape) to the low poly object?

2  Asked on December 24, 2021 by swastik-bhattacharyya

     

Smoke Transforming with Bounding Box

0  Asked on December 24, 2021 by ronn-hall

 

Transferring a texture 1 to 1

0  Asked on December 24, 2021 by gorchitsa

       

I just cant find IK (Inverse Kinematics tab in toolbar)

1  Asked on December 24, 2021 by pimpnameslickback

 

Sequencer alpha over problem

0  Asked on December 24, 2021 by felipe-del-rio

 

Ask a Question

Get help from others!

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