I am a blender noob trying to use bpy.ops.mesh.knife_project() in my script. It fails with the message:
RuntimeError: Operator bpy.ops.mesh.knife_project.poll() expected a view3d region & editmesh
Already tried this method. It fails with the same message
Here is the relevant part of my code. insulator is the active mesh object. knife is the curve object to be used as knife.
knife.select = True insulator.select = True override = context.copy() for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': override['area'] = area override['space'] = area.spaces for region in area.regions: if region.type == 'WINDOW': override['region'] = region break break bpy.ops.view3d.viewnumpad(override, type = 'BOTTOM', align_active = True) bpy.ops.view3d.view_persportho(override) #bpy.ops.object.mode_set(mode = 'EDIT', toggle = False) #bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.mesh.knife_project(override, cut_through = True)
The view changes to bottom and orthographic view, but the script halts at knife_project.
The blender python reference gives very little information about this function.