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()