I am trying to pose a hand using values read from an XML file. All the joints are parented to the previous joint and finally the fingers to the hand. Í am using the following code:
#imports
bpy.ops.wm.open_mainfile(filepath=filepath)
#load xml etc
for joint in joint_rotations:
object = bpy.data.objects[joint.name]]
rot_mat = Matrix.Rotation(joint.rotation, 4, 'X')
object.matrix_world @= rot_mat
bpy.ops.wm.save_as_mainfile(filepath=outfilepath)
The code works, when I execute it joint for joint by myself, and gives the expected result. However, when I use a for loop to iterate over all elements, I get the wrong result where all elements rotate independently of their parent. Why would a for loop of the same instructions yield a different result than the instructions themselves?

