Trouble with Context for bpy.ops.transform.translate I am having trouble figuring out the correct context for bpy.ops.transform.translate. I am currently running a script that calls a create_bounding_box addon, which I figured out how to override the context for, but after it runs I can't perform a simple object translation.

Here is the relevant parts of the code:

  bpy.ops.wm.open_mainfile(filename)
  for window in bpy.context.window_manager.windows:
    screen = window.screen
    for area in screen.areas:
      if area.type == 'VIEW_3D':
          override = bpy.context.copy() 
          break
  bpy.ops.object.select_all(action='SELECT')
  bpy.ops.mesh.boundbox_add(override)
  bpy.ops.object.select_all(action='SELECT')
bpy.ops.transform.translate(value=bpy.data.objects["BoundingBox"].location*-1)


boundbox_add is an addon, and the code is here https://github.com/sambler/addonsByMe/blob/master/create_bound_box.py

boundbox_add breaks if I don't either do the above (which I thought was overriding the context) or set bpy.context.scene.objects.active = bpy.context.scene.objects[0].  

After running boundbox_add, I get poll() error for transform stating that the context is wrong.
Could do it without using the transform.translate operator

import bpy
from mathutils import Vector
# open another file.
bpy.ops.wm.open_mainfile(filepath="/home/batfinger/3DModels/New.blend")

scene = bpy.context.scene
#scene.update()
objects = [o for o in scene.objects]
override = bpy.context.copy()
override["selected_objects"] = objects
override["object"] = objects[0]
bpy.ops.mesh.boundbox_add(override)
bbox = scene.objects.active

for o in objects:
    print(o.name)
    o.location -= bbox.location # origin after translate above

bbox.location -= bbox.location


or run for each scene in the file for scene in bpy.data.scenes

Not a fan of opening new blender file in script as above.  My suggestion would be to use a handler or run a batch command.