I've used a script to extract my bones location to a text file and I was wondering if I could use this text file to import the locations to a new project in blender using another script.

Keep in mind that I literally have no knowledge of Python (I found the script that I've used to export the bone locations from another place and kind of modified it to suit my needs) and I'm very new to blender as well and was hoping if someone could help me out here.

Here's the text file I mentioned:

Current Frame 0
Bone000: HeadX:-0.0 HeadY:-0.0 HeadZ:0.0 TailX:-0.0 TailY:0.10000000149011612 TailZ:0.0
Bone001: HeadX:-0.0 HeadY:-0.0 HeadZ:1.2218284606933594 TailX:-0.0 TailY:0.10000000149011612 TailZ:1.2218284606933594
Bone140: HeadX:-0.0 HeadY:-0.0 HeadZ:0.0 TailX:-0.0 TailY:0.10000000149011612 TailZ:0.0

This is where I found the script:


this is what I changed it to:

import bpy
start_frame = 0
scene = bpy.data.scenes["Scene"]
armature = scene.objects["Armature"]
outputfile = bpy.path.abspath("C:\\Bones.txt")
pose_list = []
rota_list = []
buffer = []
def export_bone(bone):
    pos0 = bone.head
    pos1 = bone.tail
    # log and append to buffer
    msg = "{0}: HeadX:{1} HeadY:{2} HeadZ:{3} TailX:{4} TailY:{5} TailZ:{6}".format(bone.name, pos0.x, pos0.y, pos0.z, pos1.x, pos1.y, pos1.z)
# loop all frames
print("Starting Export")
scene.frame_current = start_frame
while scene.frame_current < scene.frame_end:
    # log and append to buffer
    msg = "Current Frame {0}".format(scene.frame_current)
    # change frame
    scene.frame_current += 0
    # export all bones of armature
    for bone in armature.pose.bones:
# output buffer to file
with open(outputfile, "w") as f:

Any help would be much appreciated Cheers

  • 1
    $\begingroup$ Related: blender.stackexchange.com/questions/80230/… $\endgroup$
    – brockmann
    Commented Oct 30, 2020 at 13:02
  • $\begingroup$ hey thx for replying. yes I saw this but my problem was that the original text that the user posted which led to the answer is gone and I have no way of knowing what format it was. and as i stated earlier I have very little knowledge of python and can't understand the answer provided... $\endgroup$ Commented Oct 30, 2020 at 13:43
  • $\begingroup$ yes of course. edited to original post with the added info $\endgroup$ Commented Oct 31, 2020 at 22:50
  • $\begingroup$ Recommend, setting frame = start_frame testing with frame < scene.frame_end, changing frame with scene.frame_set(frame) and incrementing with frame += 1 $\endgroup$
    – batFINGER
    Commented Nov 1, 2020 at 1:36
  • $\begingroup$ Could you please elaborate on what your needs are. The bvh import / export creates a text file with both the rig and animation. The link posted is outputting the animation per frame. You have edited to export only the head and tail locations of each bone per frame in the animation. $\endgroup$
    – batFINGER
    Commented Nov 1, 2020 at 4:00


You must log in to answer this question.

Browse other questions tagged .