I want to create an empty for every object selected (with its coordinates) and parent each object to the empty. I found this solution
How to create an empty per object in selection?
In that link they share this code where it says "If you want the empties to be the parents :"
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)
But the nulls appear in the world's origin not in the objects' origin.
Any idea to get it?
Thanks