Sorry if this has been asked many times but I couldnt find the answer that I was looking for.
Coming from Max I used to have scripts that would place the pivot to the left, right, top or bottom of an object by the push of a button. Now im trying to create something similar in blender python but I cant for the life of me figure out how it works.
I've searched online but the answers are all pretty confusing and most of them are written for versions earlier than 2.8.
However I found a script that should place the pivot on the bottom of an object AND doesn't throw an error. BUT actually it doesn't do anything at all either. So i'm wondering why this script won't work for me?
import bpy
context = bpy.context
for obj in context.selected_objects:
mx = obj.matrix_world
minz = min((mx @ v.co)[2] for v in obj.data.vertices)
mx.translation.z -= minz
The pivot remains in the center of the object.
*instead of@in the code and will not work with newer Python in 2.8x, so it does not fully answer the question. The OP mentioned specifically "I've searched online but the answers are all pretty confusing and most of them are written for versions earlier than 2.8." I think clearing the confusion here would be in order. – Martynas Žiemys Apr 21 '20 at 08:39