How to use a pivot point to mirror mesh with script I have pivot point and cursor set as in this answer. Now I want to use it to mirror mesh of an object by running script from the text editor. Mirror works fine, but it does not use the pivot point. Does it mean I have to run the code from the 3D View, or there is a way to switch to the context, and still run it in Text Editor?

import bpy

def areas_tuple():
    res = {}                                                               
    count = 0
    for area in bpy.context.screen.areas:                                  
        res[area.type] = count                                             
        count += 1
    return res  

areas = areas_tuple()
view3d = bpy.context.screen.areas[areas['VIEW_3D']].spaces[0]
view3d.pivot_point='CURSOR'
view3d.cursor_location = (0.0, 0.0, 0.0)

bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.transform.mirror(
    constraint_axis=(True, False, False),
    constraint_orientation='GLOBAL',
    proportional='DISABLED')
bpy.ops.mesh.flip_normals()
After reading gandalf3 comment all works!

import bpy

def areas_tuple():
    res = {}      
    count = 0                                                             
    for area in bpy.context.screen.areas:
        res[area.type] = count                                            
        count += 1
    return res   

def get_region(area):
    res = None
    for region in area.regions:
        if region.type == 'VIEW_3D':
            res = region
            break 
    return region

areas = areas_tuple()
view3d = bpy.context.screen.areas[areas['VIEW_3D']].spaces[0]
view3d.pivot_point='CURSOR'
view3d.cursor_location = (0.0, 0.0, 0.0)

bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action='SELECT')
override = {
    'window': bpy.context.window,
    'screen': bpy.context.screen,
    'area': area,
    'region': get_region(area)
    } 

bpy.ops.transform.mirror(
    override,
    constraint_axis=(True, False, False),
    constraint_orientation='GLOBAL',
    proportional='DISABLED')
bpy.ops.mesh.flip_normals()