I ran the following code to reset the origin of Cube:

import bpy
# set selection
bpy.data.objects["Cube"].select = False
bpy.data.objects["Plane"].select = True

# override context
override = bpy.context.copy()
override["selected_bases"] = [bpy.data.scenes[0].object_bases["Cube"]]
override["active_base"] = bpy.data.scenes[0].object_bases["Cube"]

bpy.ops.object.origin_set(override)  # works on Plane
bpy.ops.transform.translate(override, value=(1,1,1))  # works on Cube

However this resets the origin of the Plane instead. What am I doing wrong ?


1 Answer 1


from the blender bug tracker https://developer.blender.org/T57572

operator origin_set relies on selected_editable_objects afaict, so adding override["selected_editable_objects"] = [bpy.data.objects["Cube"]] should do the trick:

  • $\begingroup$ Good to know. Thought wait a minute I tried that one unsuccessfully before commenting, on further investigation "selected_editalbe_objects" $\endgroup$
    – batFINGER
    Nov 3, 2018 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.