How to recenter origins of objects on one axis I want to use "Origin to Geometry" on multiple objects but only move the objects' origins on one axis. How do I do this?
Bounding box center

IIRC center to geometry is also the same as bounding box center. 

Test script, finds the bounding box center cog and only translates the z component.

import bpy
from mathutils import Matrix, Vector
context = bpy.context
ob = context.object
me = ob.data

bbox = [Vector(b) for b in ob.bound_box]
cog = sum(bbox, Vector()) / 8

me.transform(Matrix.Translation((0, 0, -cog.z)))


Changing last line to 

me.transform(Matrix.Translation(-cog))


will move origin to center of bounding box.