Vertex Parented empties become offset after Set Origin to 3D cursor?

As you can see on this gif, I have a mesh composed of a bunch of vertices (divided in ~15 parts). Each vertex as an empty parented to it.

It's only when I finished the parenting part that I realised that the origin of the parent mesh was not on the 3D cursor anymore (yeah, stupid I know).

Know, when I move the origin to the 3D cursor, the empties wont follow the parent mesh, as if the vertex parenting acted as a "keep offset" parenting.

In the parent tab of an empty, I can't locate any "Connected" checkbox (which I could have checked for all empties at once, then move the origin to the 3D cursor...)

Any idea ? :x

• Maybe the empties have all moved the same way? Can't you move them all back with snapping to vertex? – lemon Nov 2 '20 at 17:13
• If you parented using the UI perhaps the parent matrix has been set. Can you go to python console, and with an empty active type in C.object.matrix_parent_inverse ? If it is not Identity ( all ones and zeros), this is the issue. – batFINGER Nov 2 '20 at 17:22
• @lemon Ok it fixed the offset (that was pretty obvious, maybe I shouldn't have ask a question just for that sorry...). Although my question was answered, now, why do my empties won't follow the parent ? batFINGER's answer is probably a good hint as my matrix is set as this : Matrix(((1.0, -0.0, 0.0, 0.18431678414344788), (-0.0, 1.0, -0.0, -0.06000000238418579), (0.0, 0.0, 1.0, -0.4116193950176239), (-0.0, 0.0, -0.0, 1.0))) – Pdhm Nov 2 '20 at 17:28
• edit: you could have selected all the empties, enable snap (vertex mode) and make them snap back to their vertices – moonboots Nov 2 '20 at 17:49

Script to fix

To make the parent relation directly to the vertex, so editing will reflect position, run script below. Zeros the location of the empty and clears the parent inverse.

When setting origin to geometry of mesh both the location and parent inverse of the empties are changed, reflecting the translation of the origin location. (The (0.18, -0.06, -0.41) part of the matrix shown in comment above).

Select the mesh object (make active) and run the script.

import bpy
from mathutils import Matrix
from bpy import context

scene = context.scene
mesh_ob = context.object
empties = [e for e in scene.objects if e.parent == mesh_ob]

for e in empties:
e.matrix_parent_inverse = Matrix()
e.location = (0, 0, 0)


The UI equivalent would be select all empties, AltG clear location and AltP clear parent inverse.

Script to add empties at each vertex

Since I have touched on scripting, feel it is a good idea to include a script to add empties to each vertex of a mesh object.

Have named them "Vert<i>" where i is the index of the vert, given them circle display and 0.2 empty scale.

import bpy
from bpy import context

ob = context.object
coll = context.collection

for v in ob.data.vertices:
mt = bpy.data.objects.new(
f"Vert{v.index}",
None,
)
mt.empty_display_type = 'CIRCLE'
mt.empty_display_size = 0.2
mt.parent = ob
mt.parent_type = 'VERTEX'
mt.parent_vertices = [v.index] * 3