I have coded an Operator that tries to change the view to Top using bpy.ops.view3d.viewnumpad, and then the invoke knife_project() operator to select an area as projected by a Curve onto a mesh.
The knife_project() succeeds, and the view is indeed set to 'TOP' when my operator finishes, however, the projection vector used by the knife_project() operator is not respecting the bpy.ops.view3d.viewnumpad('TOP') call prior to the knife_project() call.
I can tell that whatever view happened to be showing at the time I invoked my Operator was used for the knife_project. I was hoping to be able to set the projection vector of the knife_project within my operator so it doesn't need to rely on interactive user input.
Is there a way to ensure that the view matrix used by knife_project() takes into account the bpy.ops.view3d command?
def execute(self, context):
bpy.ops.view3d.viewnumpad(type = 'TOP')
setupTestareaScene() # load scene, start in 'OBJECT' mode
# Operator selection
# bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects[meshObj].select = True
bpy.data.objects[curveObj].select = True
bpy.context.scene.objects.active = bpy.data.objects[meshObj]
# Select target area with projectorCurve
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.knife_project()
Thanks, Jon

Operator selection
bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[meshObj].select = True bpy.data.objects[curveObj].select = True bpy.context.scene.objects.active = bpy.data.objects[meshObj]
Select target area with projectorCurve
bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.knife_project()
– Jonathan Schmid Dec 20 '15 at 00:26