import bpy from mathutils import Matrix act = bpy.context.active_object # Parent selected objects to active, empty the inverse matrix and preserve the world matrix. for o in bpy.context.selected_objects: if o==act: continue mat_world = o.matrix_world.copy() o.parent_type = 'OBJECT' o.parent = act o.matrix_parent_inverse = Matrix.Identity(4) o.matrix_world = mat_world