0

Edit: The problem was that I did not update the scene after scaling the object.

I am trying to move the origin of the object to the center of its bounding box.

I tried this solution Get center of geometry of an object

o = bpy.context.object

vcos = [ o.matrix_world @ v.co for v in o.data.vertices ] findCenter = lambda l: ( max(l) + min(l) ) / 2

x,y,z = [ [ v[i] for v in vcos ] for i in range(3) ] center = [ findCenter(axis) for axis in [x,y,z] ]

bpy.context.scene.cursor.location = center

bpy.ops.object.origin_set(type='ORIGIN_CURSOR')

This is how it always ends up:

Clearly, the origin doesn't sit at the center of the bounding box. Any help would be greatly appreciated!

Max
  • 101
  • 2
  • The next code snippet from answer (below code used in post above) uses the bounding box. global_bbox_center – batFINGER Jul 31 '20 at 16:23
  • For some reason both of the examples give me the same results. Which seems to be closer to center of mass than center of bounding box. – Max Jul 31 '20 at 16:26

0 Answers0