# Align pivot point to bottom back left of object

Thank you for the great script.

I have tried to use this script, but I want a slightly different setup. Do you know how you can change this script so the pivot point is set to the bottom left back?

import bpy
from bpy import context as C

for z, co in [(o.bound_box[0][2], v.co) for o in C.selected_objects for v in o.data.vertices]:
co.z -= z

• We have no idea what you're talking about without more context! Jul 29, 2022 at 16:48

Something like this should do the trick.

import bpy
import numpy as np
from mathutils import Vector, Matrix

obj = bpy.context.object
mesh = obj.data

# get the lowest point in all 3 axes for the object bounding box
#this should be the bottom-left

bb = obj.bound_box
bb_locs = np.array([v[:] for v in bb])
bot_left = []

for i, row in enumerate(bb_locs.transpose()):
# go through each row in the bounding box axes
# if the axis is "Y"
if i == 1:
# get the greatest value in that row:
val = max(row)
else:
# otherwise get the lowest value
val = min(row)
bot_left.append(val)

bot_left = Vector(bot_left)

# make a translation matrix that will move the mesh in the opposite direction
# leaving the origin in place.
mat = Matrix.Translation(-bot_left)
if mesh.is_editmode:
bm = bmesh.from_edit_mesh(mesh)
bm.transform(mat)
bmesh.update_edit_mesh(me, False, False)
else:
mesh.transform(mat)

mesh.update()

# then move the entire object by the matrix itself.
# Which puts the object back where it was with the origin in the new location.

obj.matrix_world.translation = bot_left



Result:

• Wow, thank you so much, can I ask you what I can change to make it the back rather than the front. also can it do it to multiple selected mesh's? i.e. all selected objects? Really sorry for the silly novice questions, I just have no clue about Python. very sorry in advance. !Valid XHTML. Aug 1, 2022 at 8:15
• I edited it to suit that need. Aug 1, 2022 at 20:32
• Perfect, thank you so much. Aug 2, 2022 at 8:25