Trying to replace objects location with another(bone controls)

Hey guys, I’m working on an auto rigging script and I’m trying to get newly bone controls to match previously made controls.

I have a rig I’m referencing that have controls made using the bone widget add-on. My logic is that on the auto rig, I manually create the controls again using the bone widget add-on(since I don’t know how to use an addon in python) and that the locations of the controls from the rig I’m referencing and subtract them from each other to get same relative scale, location(relative to the local location), and rotation of the controls on my auto rig. Which I believe should work since TL:DR the controls local positions start at the same place, the reference controls moved from that local position, so I should just be able to get the difference to move the auto rig controls to the same orientation/position.

But that doesn’t seem to work. Using the subtracted values only slightly move the object, I tried just using the vertex locations of the reference rig controls and that doesn’t move them at all. Any tips?

Script to get the locations of the controls I want -

# this get's all the points locations of a control object and put them into a dictionary and export them.

mesh_list = get_list_of_objs_in_coll('CTRLS')
mesh_list.sort(key=lambda x: x[:6])

start_points = dict.fromkeys(mesh_list)        

for obj in mesh_list:
   if obj in start_points:
       temp = []
       points = points_list(obj)
       for item in points:
           temp.append(tuple(item))
       start_points[obj] = temp

print(start_points)


with open('O:\\Onedrive\\Python_Blender\\blend_auto_rig\\Custom_Auto_Rig\\start_points.txt', 'w') as file:
       # file.write(json.dumps(a_list))
       json.dump(start_points, file, ensure_ascii=False)
       print('finished!')

then I get the the locations of the controls I want to change(which local position has the same starting position as the locations above) using the same code

Script to change the location of the controls -

# was attempting to get the difference between starting points and where the points end up so I can move them, but it only moved a little
distance_between_points = dict.fromkeys(start_points)


for key, value in start_points.items():
    distance_between_points[key] = []
    for index, vert in enumerate(value):
        distance = list(map(lambda a, b: a - b, end_points[key][index], vert))
        distance_between_points[key].append(tuple(distance))

obj_coll = get_list_of_objs_in_coll('CTRLS')
count = 0
for item in obj_coll:
    if item in distance_between_points:
        obj = clean_select(item)
        bpy.ops.object.mode_set(mode='OBJECT')
        obj = bpy.data.objects[item]
        obj.select_set(True)
        bpy.context.view_layer.objects.active = obj
        bpy.ops.object.mode_set(mode='EDIT')
        bpy.ops.mesh.select_all(action='SELECT')
        mesh = bpy.context.view_layer.objects.active.data
        bpy.ops.object.mode_set(mode='EDIT')
        if obj.mode == 'EDIT':
                bpy.ops.object.mode_set(mode='OBJECT')
            # Get the selected vertices
                selected_verts = [v.co for v in obj.data.vertices if v.select]
                print(len(selected_verts))
            # Move the selected vertices
                for index, vert in enumerate(selected_verts):
                    print(len(distance_between_points[key]))

                # You can adjust the movement by changing these values
                    vert.x += distance_between_points[item][index][0]
                    vert.y += distance_between_points[item][index][1]
                    vert.z += distance_between_points[item][index][2]    

I rewrote the script and got it working. For some reason, if I made a variable of a list/dictionaries of vertices, it would change the values for some reason when I selected another mesh. So, I wrote it that it makes a hard copy file(a text file) with all the positions and imported and used that to move the points -