I am trying to transfer position of 2 points into a bone, so that the bone has the same direction as the 2 points I tried it with this initial position this is the output after running the code
this is the code
import bpy
from mathutils import Vector, Quaternion
use_bone = bpy.data.objects['Armature'].pose.bones['Bone']
p1 = bpy.data.objects['Point.001'].location
p2 = bpy.data.objects['Point.002'].location
p_v = p2-p1
loc_h = Vector(use_bone.head)
loc_t = Vector(use_bone.tail)
loc_v = loc_t - loc_h
q = loc_v.rotation_difference(p_v)
use_bone.rotation_quaternion = use_bone.rotation_quaternion @ q
It doesnt even close to what I was expecting, anyone please help
Edit: I tried XY comments, if the bone has random head and tail, the script doesnt work.... this is the example : initial After run the code
I appreciate the help, just a little bit more help :)