How to Unwrap project from view with script? I was trying to make a importer/exporter and place a UV mapping operation in the middle. my only issue is that when I try to a unwrap_project_from_view it gives me null results.

what is the correct way to unwrap_project_from_view a mesh in from a top view with ortho??

My current progress:

import bpy

# Variables
obj_file = "D:\\HUD move left\\OBJs\\HUD Move_Left Grey_000172.obj"
dae_file = "D:\\HUD move left\\DAEs\\HUD Move_Left Grey_000172.dae"
hud_object = 'HUD Move_Left Grey_000172'

# Import OBJ
bpy.ops.import_scene.obj(filepath=obj_file)

# Set active Object
object = bpy.data.objects[hud_object]
bpy.context.scene.objects.active = object

# Search for 3D Area on layout
for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        space_data = area.spaces.active

        # Change to Edit mode
        bpy.ops.object.mode_set(mode = 'EDIT')

        # Unwrap (!!! NOT WORKING YET !!!)
        if bpy.ops.uv.project_from_view.poll():
            bpy.ops.uv.project_from_view(orthographic=True, scale_to_bounds=True)

        # Change to Object mode
        bpy.ops.mesh.select_all(action = 'DESELECT')
        bpy.ops.object.mode_set(mode = 'OBJECT')

        break

# Export DAE
bpy.ops.wm.collada_export(filepath=dae_file)

# Delete Mesh in Scene
bpy.data.objects[hud_object].select = True
bpy.ops.object.delete()
I bumped into the same issue and finally solved it!
you just need to have a 3d viewport opened with your desired view and run this script:

import bpy

for obj in bpy.context.selected_objects:
    bpy.context.scene.objects.active = obj
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action= 'SELECT')
    for area in bpy.context.screen.areas:
        if area.type == 'VIEW_3D':
            for region in area.regions:
                if region.type == 'WINDOW':
                    override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object}
                    bpy.ops.uv.project_from_view(override , camera_bounds=False, correct_aspect=True, scale_to_bounds=True)
    bpy.ops.object.mode_set(mode = 'OBJECT')


Hope I helped you!

Cheers!