Aligning empty object with Bezier curve point using Python I'm using a Bezier curve to generate a shape. Once I'm happy with the shape I process it with a script I wrote. Among other things it adds 2 empty objects: one at the start of the curve, one at the end of the curve. 

I can't figure out how to rotate the empty objects so that they point in the same way the curve is pointing. Or how to align the empty's Y axis to the end point normal?

I access the end point data via curve.data.splines.active.bezier_points[pointId] but I couldn't find a way to get rotation or normal information.

Orientation that I'm trying to copy from curve end point to empty axis orientation.



End result I'm trying to achieve: the empty's Y axis is aligned with the direction of the last curve point.
Use the follow path constraint

When it comes to putting an object at either end of a curve, the follow path constraint, with fixed location, follow curve. An offset factor of 0 is one end, 1 the other.



import bpy

context = bpy.context
bez = context.object

bpy.ops.object.empty_add(location=(0, 0, 0))
mt1 = context.object
fpc = mt1.constraints.new(type='FOLLOW_PATH')
fpc.target = bez
fpc.use_curve_follow = True
fpc.use_fixed_location = True
# dupe it
bpy.ops.object.duplicate()
mt2 = context.object
mt2.constraints[0].offset_factor = 1