How to create an empty per object in selection? How can I create an empty / null / locator object using python? I'd like to create one for each selected object and then all empties should be parented or constraint to the selected objects, meaning that the rotation and position should be copied over as well.
I tried something along these lines but I can't get it to work properly:
import bpy

for obj in bpy.context.selected_objects:
    bpy.ops.object.empty_add()

Q: How to create an empty per object in selection?
Update for 2.8 +
import bpy

for obj in bpy.context.selected_objects:  # Loop over all selected objects
    empty = bpy.data.objects.new(obj.name + &quot;_Empty&quot;, 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

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 + &quot;_Empty&quot;, 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)