You'll need this script:
import bpy
from mathutils import Vector
import bmesh
context = bpy.context
def global_origin_to_bottom(obj):
mw = obj.matrix_world
bm = bmesh.new()
bm.from_mesh(obj.data)
global_verts = [mw * Vector(v[:]) for v in obj.bound_box]
print(global_verts)
l = len(global_verts)
x = sum([v.x for v in global_verts]) / l
y = sum([v.y for v in global_verts]) / l
z = min([v.z for v in global_verts])
global_origin = Vector([x, y, z])
local_origin = mw.inverted_safe() * global_origin
for v in bm.verts:
v.co = v.co - local_origin
bm.to_mesh(obj.data)
#move the mesh back
mw.translation = global_origin
def origin_to_bottom(obj):
mw = obj.matrix_world
local_verts = [Vector(v[:]) for v in obj.bound_box]
bm = bmesh.new()
bm.from_mesh(obj.data)
x, y, z = 0, 0, 0
l = len(local_verts)
'''
# will give a modified center
# eg if array modifier will be centre of array
y = sum([v.y for v in local_verts]) / l
x = sum([v.x for v in local_verts]) / l
'''
z = min([v.z for v in local_verts])
local_origin = Vector((x, y, z))
global_origin = mw * local_origin
for v in bm.verts:
v.co = v.co - local_origin
bm.to_mesh(obj.data)
#move the mesh back
mw.translation = global_origin
#test
mesh_objs = [mo for mo in context.selected_objects if mo.type == 'MESH']
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
for o in mesh_objs:
origin_to_bottom(o)
#global_origin_to_bottom(o)
Save it as a txt file. Open the txt file with Blender Script Editor, select your objects and hit "Run Script".
Make sure to apply Rotation to the objects first if you have rotated them. Rotation X, Y and Z should be zero.
If not select your objects, press Ctrl + A and select Rotation.
To set all these objects to a specific Location Alt + Click into the Location Value, type your desired value and hit enter.
If you want to move the objects to the height of a different object you can snap your cursor to other Vertices or Objects and copy the location of your 3D Cursor to your objects that you wish to move.
If you use it as often as I do save it into your start-up file. Right click on the Menu Bar of the Text Editor, select collapse menus and tuck it away to the side like I did: