From the text_editor templates > python > operator_file_export.py . Changed the write_some_data function to export matrix_world location of active object.
Just using location
and rotation_euler
will not give visual location when there are constraints or follow_path (et al).
def write_some_data(context, filepath, use_some_setting):
print("running write_some_data...")
camera = context.active_object
mw = camera.matrix_world
scene = context.scene
frame = scene.frame_start
f = open(filepath, 'w', encoding='utf-8')
while frame <= scene.frame_end:
scene.frame_set(frame)
x, y, z = mw.to_translation()
rx, ry, rz = mw.to_euler('XYZ')
f.write("%d" % frame)
f.write(", ")
f.write("%5.3f, %5.3f, %5.3f" % (x, y, z))
f.write(", ")
f.write("%5.3f, %5.3f, %5.3f" % (rx, ry, rz))
f.write("\n")
frame += 1
f.close()
return {'FINISHED'}