Comparing object against itself after being linked

Hi all,

Let’s say I have 3 chairs (A,B,C)
A and B chairs are the same but C chair (is the same mesh than A and B) has its origin rotated 180. When I link B and C to A, the B will be visually without change meanwhile the C will be obviously rotated because the origin.

Now the thing I’m looking after is to make a script “smart” enough to know if the mesh has changed after being linked and the ones that has being changed will not be linked.

Following the given example, when running the script while selecting B and C and having A as active object and link the object data, the script should link only the A and B and keeping C unlinked and selected.

I have done a little bit of code but not sure how to continue from here or even if this is the right approach.
In my script I’m comparing the matrix against itself before and after being linked to another object, but that’s it :sweat_smile:

import bpy

# OLD OWN COORD
old_ob = bpy.data.objects["Cube.001"]

#OLD LOCAL VERTICES
old_v = old_ob.data.vertices[0].co
old_mat = old_ob.matrix_world

#OLD GLOBAL VERTICES
old_loc = old_mat @ old_v


bpy.ops.object.make_links_data(type='OBDATA')


# NEW OWN COORD 
new_ob = bpy.data.objects['Cube.001']

#NEW LOCAL VERTICES
new_v = new_ob.data.vertices[0].co
new_mat = new_ob.matrix_world

#NEW GLOBAL VERTICES
new_loc = new_mat @ new_v

if old_loc != new_loc:
    print('HAS CHANGED')

else:
    print('NO CHANGE')

    

Thanks in advance,
Juan

this will work so long as the vertex order has not changed- which shouldn’t be a problem if the data is linked. That said, if the data is linked you know the meshes are identical- which means the only thing that can be different is the object’s transform. far easier to just compare the two object’s world matrices, no?

No matter if an object is linked or not the world matrices always changes if the two linked objects are not in the same place, right?