Help getting a list of bones in a rig using python

I have tried the script here without any luck to get the names of the bones in the “rig” hierarchy ( green bones ) . https://blender.stackexchange.com/questions/42431/list-of-bones-to-file-is-it-possible

Its related to this request: https://github.com/saturday06/VRM-Addon-for-Blender/issues/397

I’d prefer that the names are written to a file if possible.

This prints the tree in Blender’s console. You should be able to take it from here if you can program:

import bpy

def list_children(bone, level=0):
    for i in range(level*2):
        print(" ", end="")
        
    print(bone.name)
    
    if len(bone.children) > 0:
        for child_bone in bone.children:
            list_children(child_bone, level+1)
            
list_children(bpy.data.armatures['rig'].bones[0])

I can’t program sadly.

Well, if you could be more specific about exactly what you need, I could get a basic one going for you based on this. I couldn’t really figure out from the github issue exactly which bones you want, since it sounds like you want to filter some out.

If you run this script from the Text Editor in Blender in your blend file and then post the console output(Window → Toggle System Console), along with a second copy of all the bones you don’t want in the list removed, that would help too.

Note: On Linux the window → system console does not exist. Simply run blender from the command prompt and it will print the bone list in that window when the script is run.

I also changed

for i in range(level*9):

This is all the bones.
boneslist.txt (30.6 KB)