I’m trying to write a script for automatic animation, but I’m stuck in getting the bone position in pose mode. Could anyone point me the good method ?
So far, I
Get the armature using bpy.context.objects[‘Armature’]
Reference the bones by armature.data.bones[‘NameOfTheBone’]
I’m able to move the bones by script by selecting them through armature.data.bones[‘NameOfTheBone’].select = True and bpy.ops.transform.translate/rotate
However, I can’t figure out how to get their positions in pose mode
Any tips ?
This line “Armature.blenderObject.pose.bones[‘BoneName’].location” gives a vector with zeros as its value.
The thing is i want to pair an object to a bone in an armature but each time i change scene and go back to the previous scene where the paired object is, the object is moved away from its Original position while still being paired to its parent. How can i stop this object from moving when i change scenes.
Note: it’s parent object has an animation being played in run time
Bone Test.blend (895.4 KB)
Sorry, I just read you asked for pose mode, here’s an example for that, move Bone.002 in pose mode, and then run the script and it will put the empty over that bone.
The armature was posed with a different animation (A) but the game is set in a way that the armature plays a different animation (B) during runtime. Due to this, any object paired to the armature during scene change (back and forth scene change) gets displaced or slightly moved away from its original point.