How to import bone locations form a text file? 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:
https://blenderartists.org/t/save-bone-position-and-rotation-in-a-txt-file/1219916
this is what I changed it to:
import bpy
    
start_frame = 0
scene = bpy.data.scenes[&quot;Scene&quot;]
armature = scene.objects[&quot;Armature&quot;]
outputfile = bpy.path.abspath(&quot;C:\\Bones.txt&quot;)
    
pose_list = []
rota_list = []
buffer = []
    
def export_bone(bone):
    pos0 = bone.head
    pos1 = bone.tail
    # log and append to buffer
    msg = &quot;{0}: HeadX:{1} HeadY:{2} HeadZ:{3} TailX:{4} TailY:{5} TailZ:{6}&quot;.format(bone.name, pos0.x, pos0.y, pos0.z, pos1.x, pos1.y, pos1.z)
    print(msg)
    buffer.append(msg)
    
# loop all frames
print(&quot;Starting Export&quot;)
scene.frame_current = start_frame
while scene.frame_current &lt; scene.frame_end:
    # log and append to buffer
    msg = &quot;Current Frame {0}&quot;.format(scene.frame_current)
    print(msg)
    buffer.append(msg)
        
    # change frame
    scene.frame_current += 0
    
    # export all bones of armature
    for bone in armature.pose.bones:
        export_bone(bone)
    
# output buffer to file
with open(outputfile, &quot;w&quot;) as f:
    f.write(&quot;\n&quot;.join(buffer))'

Any help would be much appreciated
Cheers
The script you have doesn't dump a lot of important information, like the bone roll, or parenting info.
Assuming you're trying to dump the editbone info, this script should work. By default it exports. Change command in the options at the top to 'IMPORT' to import instead.
# !!!! Options, edit me!
path = 'C:\\Bones.json'
command = 'EXPORT'  # EXPORT or IMPORT
# !!!!

import bpy
bone_props = [
    'name', 'head', 'tail', 'roll', 'use_connect',
    'use_local_location', 'use_inherit_rotation', 'inherit_scale',
]
if command == 'EXPORT':
    ob = bpy.context.view_layer.objects.active
    if ob and ob.type == 'ARMATURE':
        pass
    else:
        obs = [ob for ob in bpy.data.objects if ob.type == 'ARMATURE']
        if len(obs) == 1:
            ob = obs[0]
        else:
            raise RuntimeError('Select an armature')
    arma = ob.data

    data = {}
    data['armature'] = {}
    data['armature']['name'] = arma.name

    if bpy.context.mode != 'OBJECT':
        bpy.ops.object.mode_set(mode='OBJECT')
    bpy.context.view_layer.objects.active = ob
    bpy.ops.object.mode_set(mode=&quot;EDIT&quot;)

    data['edit_bones'] = []
    for ebone in arma.edit_bones:
        bonedata = {}
        bonedata['parent'] = ebone.parent.name if ebone.parent else None
        for prop in bone_props:
            val = getattr(ebone, prop)
            if prop in ['head', 'tail']: val = list(val)
            bonedata[prop] = val
        data['edit_bones'].append(bonedata)

    bpy.ops.object.mode_set(mode=&quot;OBJECT&quot;)

    with open(path, 'w') as f:
        import json
        json.dump(data, f, indent=2)

elif command == 'IMPORT':
    with open(path, 'r') as f:
        import json
        data = json.load(f)

    arma = bpy.data.armatures.new(data['armature']['name'])
    ob = bpy.data.objects.new(arma.name, arma)
    bpy.context.collection.objects.link(ob)

    if bpy.context.mode != 'OBJECT':
        bpy.ops.object.mode_set(mode='OBJECT')
    bpy.context.view_layer.objects.active = ob
    bpy.ops.object.mode_set(mode=&quot;EDIT&quot;)

    for bonedata in data['edit_bones']:
        arma.edit_bones.new(bonedata['name'])

    for bonedata in data['edit_bones']:
        ebone = arma.edit_bones[bonedata['name']]
        if bonedata['parent']:
            ebone.parent = arma.edit_bones[bonedata['parent']]
        for prop in bone_props:
            setattr(ebone, prop, bonedata[prop])

    bpy.ops.object.mode_set(mode=&quot;OBJECT&quot;)