Adding Empties at mesh centers? / Script?

It this excellent tutorial, starting at 8:00 the present showcase the SVG workflow. At one point he manually (?) adds Empties at the center of many text objects, ie individual letters.

I ask if there’s a script that does, repeatedly, “add an Empty at the center of every selected object” ?

There might be subtleties such as “add at Origins” or “add at Mesh center” too.

Here’s a script that adds an Empty at every selected Object’s origin, then makes the empty the parent of the object:

import bpy

for obj in bpy.context.selected_objects: # Loop over all selected objects
empty = bpy.data.objects.new(obj.name + “_Empty”, None) # Create new empty object
obj.users_collection[0].objects.link(empty) # Link empty to the current object’s collection
empty.empty_display_type = ‘PLAIN_AXES’
empty.location = obj.location
obj.parent = empty
obj.location = (0, 0, 0)

+++++++++++++++++
Here’s another that makes the Empty a child of the selected object:

import bpy

for obj in bpy.context.selected_objects:  # Loop over all selected objects
    empty = bpy.data.objects.new(obj.name + "_Empty", None)  # Create new empty object
    obj.users_collection[0].objects.link(empty)  # Link empty to the current object's collection
    empty.empty_display_type = 'PLAIN_AXES'
    empty.parent = obj

These were found at: https://blender.stackexchange.com/questions/134879/how-to-create-an-empty-per-object-in-selection

empty.location = obj.location is not true world coordinate. What happens if this object is under multiple parents?

Then you use a different script.

you can also change it to empty.matrix_world() = obj.matrix_world(), which feels like the easier solution in all this :stuck_out_tongue: