How to position the origin of an object next to edges of another object with python
If both objects origins are at their centers ; set their names in the script and run it :

import bpy

cone = bpy.data.objects['Cone']
box = bpy.data.objects['Cube']

edge = box.dimensions[2]/2 + box.location[2]
cone.location[2] = edge-0.1  #assuming 1BU-&gt;1cm