How to uv unwrap object with python I am creating a siding generator and I want it to add image textures to the model and uv unwrap them, but I am having one pain of a time getting around the bpy.ops.uv.smart_project.poll() context. I have tried overriding the context and setting it and a bunch of other things, no luck though. Any help is much appreciated
This method works:

import bpy

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.smart_project(override)


the important thing is passing override to whatever operator you are trying to call, this forces it to take that context for a brief moment. You can read a little about it at http://www.blender.org/documentation/blender_python_api_2_72_release/bpy.ops.html?highlight=override