1

I want to read the data of my armature (specifically each bone) but the problem is the value of one of my axis does not change

This is a part of my code

foot_L = bpy.data.objects['metarig'].pose.bones['foot.L']

for iteration in range(1,15):

    foot_L.bone.select = True
    print("foot_L.location =", foot_L.location)

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
Hesam .K
  • 13
  • 2
  • In a comment to an answer you say, in effect, that the code snippet in your question doesn't reflect the code that's showing the problem. Please include a complete blend file that does show the problem, or nobody will be able to help you. (How to add a blend file) – Marty Fouts Oct 12 '21 at 13:48

1 Answers1

0

If you want the position of the bones as they appear in pose mode, here is the loop for your print.

for bone in bpy.data.objects['metarig'].pose.bones:
    print(f'{bone.name}.location = {bone.location}')

If you want the position of the bones as they appear in edit mode, you don't want to use the object, but rather the armature, and you need to print locations for both head and tail:

for bone in bpy.data.armatures['metarig'].bones:
    print(f'{bone.name}')
    print(f'\t head = ({bone.head[0]:5.2f}, {bone.head[1]:5.2f}, {bone.head[2]:5.2f})')
    print(f'\t tail = ({bone.rail[0]:5.2f}, {bone.tail[1]:5.2f}, {bone.tail[2]:5.2f})')

Although you might want to make the print of the positions prettier.

Marty Fouts
  • 33,070
  • 10
  • 35
  • 79
  • this was a sample of my code for one bone but with this command, I have not got the correct answer I'm looking for a command for this issue – Hesam .K Oct 12 '21 at 13:25
  • 1
    I understand you I meant you use the .location command like me in your code but these command does not return a correct value to me for more explanation, I can say this: I need the location of some bones which are not translated but their position changes because of the effect of the other bones in my model, I just rotate and translate some bones, and others are influenced by rotated and translated bones – Hesam .K Oct 13 '21 at 10:13