How do I get knife_project operator to use view settings within the operator?
To get this to work you need to do a few things:


To override the context of the knife_project operator (which is necessary for running it outside the 3D view UI).
To force the view to move to TOP without using the viewnumpad operator, which doesn't come into effect until your script is finished, even if you try to force redraw the scene.
So to do this, you can rotate the view directly using the 3D view's region object (this is how you set the projection vector).
Then you need to force redraw the scene in a way that's kind of risky and considered bad practice, but I know of no other way to do this (bpy.ops.wm.redraw_timer). If this is not used, the view angle isn't updated and the knife projects from the current camera view. EDIT: Well there is one slightly cumbersome way come to think of it, you can wrap this whole thing with a Modal Operator. Here's a nice example of this.


Here's how the code looks like (This code works only after you already have both objects selected, and the target object in edit mode):

import bpy
from mathutils import Euler

def view3d_find( return_area = False ):
    # returns first 3d view, normally we get from context
    for area in bpy.context.window.screen.areas:
        if area.type == 'VIEW_3D':
            v3d = area.spaces[0]
            rv3d = v3d.region_3d
            for region in area.regions:
                if region.type == 'WINDOW':
                    if return_area: return region, rv3d, v3d, area
                    return region, rv3d, v3d
    return None, None

region, rv3d, v3d, area = view3d_find(True)

# Define context override dictionary for overriding the knife_project operator's context
override = {
    'scene'            : bpy.context.scene,
    'region'           : region,
    'area'             : area,
    'space'            : v3d,
    'active_object'    : bpy.context.object,
    'window'           : bpy.context.window,
    'screen'           : bpy.context.screen,
    'selected_objects' : bpy.context.selected_objects,
    'edit_object'      : bpy.context.object
}

# Set view to TOP by directly rotating the 3D view region's view_rotation
rv3d.view_rotation = Euler( (0,0,0) ).to_quaternion()

# Force redraw the scene - this is considered unsavory but is necessary here
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)

bpy.ops.mesh.knife_project(override)