I have about 30 planes and would like to add an empty to each one of them, is there a way to do it using python instead of having to do it manually?
1 Answer
For Blender >2.80 this will work. Select all your objects and run this in the scripting panel.
import bpy
for object in bpy.context.selected_objects:
obj_loc = object.location
new_empty = bpy.data.objects.new( "empty", None )
new_empty.location = obj_loc
object.parent = new_empty # swap this line around to parent the other way
object.matrix_world = object.matrix_parent_inverse
bpy.context.scene.collection.objects.link( new_empty )
This will create new emptys at the object origins of all the selected objects, parent the object to the empty and remove any offset between the object and the empty.
-
$\begingroup$ when swapping the last line an empty is added but I'd like it to be at the object origin. $\endgroup$ Nov 25, 2020 at 13:38
-