#!BPY

""" Registration info for Blender menus:
Name: 'Bone Data Test'
Blender: 233
Group: 'Export'
Tip: 'Print The Bone Data.'
"""

import Blender
import sys, os, os.path, struct, math

from Blender import Types, Object, Mathutils
from Blender.Mathutils import *

def BoneDataOut():
    for obj in Blender.Object.GetSelected():
        Armat = obj.getData()
        print "Object type:", type(Armat)
        if type(Armat) is Blender.Types.ArmatureType:
            continue
        for bo in Armat.bones:
            bh = bo.head
            bt = bo.tail
            bloc = bo.loc
            test = bh - bt
            print 'Bone Name',bo.name
            if (bo.hasIK() == 1) : print "\tbone has IK"
            else : print "\tbone lacks IK"
            myp = bo.parent
            if (myp  != None )
                print '\tHAs parent:', myp.name
                print '\t\tparent head:', myp.head
                print '\t\tPatent location:',myp.loc
            print '\tbone location:', bloc
            print '\tBone Head:',bh.x,'Y:', bh.y,'z:', bh.z
            print '\tHEad Mag :',bh.length

                        print '\tBone Tail- X:', bt.x,'Y:', bt.y,'z:', bt.z
            print '\ttail Mag :',bt.length

            print '\tBone Quats\n\t\t X:',bo.quat.x,'y:',bo.quat.y,'z:',bo.quat.z,'w:',bo.quat.w
            QA = bo.getRestMatrix('worldspace').toQuat()
            print '\t\t Worldspace Quat:\n\tX',QA.x,'y:',QA.y,'z:',QA.z,'w:',QA.w
            QA = bo.getRestMatrix('bonespace').toQuat()
            print '\t\t Bone space Quat:\n\tX:',QA.x,'y:',QA.y,'z:',QA.z,'w:',QA.w
            print '\tBone Size:',bo.size


print "Testing output.... \n\n\n"
BoneDataOut()
