3
$\begingroup$

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 ?

$\endgroup$
1

1 Answer 1

3
$\begingroup$

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:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .