BGE Blender 2.78a convert camera Bezier curve follows to real animation data <script>

BGE Blender 2.78a convert camera Bezier curve follows to real animation data

#2.78a Blender, Bezier To Animation-Graph, Python 3.5
import bpy

#current active and selected objects
Main = bpy.context.active_object
Tertiary = bpy.context.selected_objects[0]

# Create an override context for the 3D View
for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        # Copy the current context and override the area
        override = bpy.context.copy()
        override['area'] = area
        
        # Find a region of type 'WINDOW' within the area
        for region in area.regions:
            if region.type == 'WINDOW':
                override['region'] = region
                break
        
        print(bpy.context.active_object)
        print(bpy.context.selected_objects[0])
        
        if bpy.context.scene.frame_current < bpy.context.active_object.game.properties["TrailorFrameBreak"].value:
            # Now call the operator with the overridden context
            bpy.ops.view3d.snap_selected_to_active(override)
            #then set tertiary objects rotation to Mains.
            import random
            Tertiary.rotation_euler[0] = Main.rotation_euler[0]
                    
            bpy.context.scene.frame_current += 1
            bpy.ops.object.select_all(action='DESELECT')
            
            Tertiary.select = True
            bpy.context.scene.objects.active = Tertiary
                    
            #Add frame.
            bpy.ops.anim.keyframe_insert_menu(type='__ACTIVE__', confirm_success=True)
    
            #return to normalcy
            Main.select = True
            bpy.context.scene.objects.active = Main 
            #then we repeat.
        break

#think we could do something like:
#bpy.ops.wm.redraw_timer() or bpy.context.scene.update()
#but whatever it works well enough so I don't really care.

#it loses graph quality as the program continues (perhaps due to failure in snapping?)
#Location may be slightly slower than the original and rotation might follow in a seperate angle
#location is so miniscule it can be ignored, rotation can be rectified in the graph editor.
#couldn't get a for-loop to work, just tap ALT+P until you have all the frames you require
#it does the same thing anyways. yes I did consider using a modal, didn't bother.
#you'll need to have the 3d screen active while you run this script in the text editor
#I'm fully aware of how awkward this script works, it's clearly not my best work.

select your object then your camera then run this and you’ll be able to finally convert bezier follow paths into real animation data for your camera object to use.