Blender doesn't have a tool built-in to perform this operation currently.
If you would write your own tool, a method you can use to achieve this using Python.
- Define the source vector (face normal in this case).
- Define the destination vector (the axis vector).
- Use the rotation between these vectors to define a 3D rotation
(see Vector.rotation_difference). - Then rotate your object by this.
This example uses the normal of the first face, assumes object
import bpy
from mathutils import Matrix, Vector
obj = bpy.context.object
matrix_orig = obj.matrix_world.copy()
# for this example just pick the first face.
axis_src = matrix_orig.to_3x3() * obj.data.polygons[0].normal
# z-axis, could be any direction
axis_dst = Vector((0, 0, 1))
matrix_rotate = matrix_prevmatrix_orig.to_3x3()
matrix_rotate = matrix_rotate * axis_src.rotation_difference(axis_dst).to_matrix()
matrix_translation = Matrix.Translation(matrix_orig.to_translation())
obj.matrix_world = matrix_translation * matrix_rotate.to_4x4()