Hey, I’m trying to move a bone to a location of an empty, but it moves to an incorrect position. Can someone please take a look? Ty
As you see I tried to move two bones, and they don’t end up at the same location. My guess is that I’m not grabbing the the right location vector. But I’m not quite sure how to do this.
To test spawn an armature, extrude a bone and disconnect it. Also, add one empty. Then the script should work.
import bpy from bpy import context armature = "Armature" pose_bone = context.active_pose_bone obj_empty = bpy.data.objects["Empty"].location tst = bpy.data.objects[armature].matrix_world.inverted() loc = tst @ obj_empty print(obj_empty) print (loc) print (tst) bpy.data.objects[armature].pose.bones["Bone.001"].location = loc bpy.data.objects[armature].pose.bones["Bone"].location = loc