What I want:
I want to set the origin of an object to the center of its bounding box using a python command.

What I've tried:




What happened:
Image of a not-centered origin

As you can see, the origin isn't centered to the bounding box.

EDIT: I asked the same question as Get center of geometry of an object with the addition of setting the origin to this center.

  • $\begingroup$ The origin moved to the center of mass. It is now centered, where do you suppose the center is suposed to be. Do you mean the center of the bounding box? $\endgroup$
    – Leander
    Commented Dec 29, 2016 at 20:11
  • $\begingroup$ iam talking about the bounding Box. $\endgroup$
    – froggyman
    Commented Dec 29, 2016 at 20:13
  • $\begingroup$ From Get centre of geometry, the local centre is (0, 0, 0) to move the origin, subtract (transform) the new local location vector from the vert coordinate locations. $\endgroup$
    – batFINGER
    Commented Dec 30, 2016 at 13:27

2 Answers 2


Have you tried setting the center to BOUNDS?

bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')

I noted that this can be further confusing if you have a group with joined geometry inside it.

objGrp = bpy.data.objects.new(scn.baseName, None)

if objGrp has children that have there own origin set wrong sleecting it in the view will still have the origin wrong while the group parent object might be fine. In this case you simply need to make sure you've selected the internal object first and the same will apply.

So Center of Mass etc. will work as expected on the kid too. Here we see this situation where a bunch of generated objects are joined and then have the center set. Still maybe you want to loose the parent object at that point but it's just an example of how the Question poster (or others with this variation) might have not see the desired effect.

obs = objGrp.children
ctx = bpy.context.copy()

ctx['active_object'] = obs[0]
ctx['selected_objects'] = obs
ctx['selected_editable_bases'] = [scn.object_bases[ob.name] for ob in obs]

ob = bpy.ops.object
obs[0].select = True

You must log in to answer this question.

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