here’s some suggestions for adding more options
------------------------------------------------------------------------
REST ON GROUND
#---------------------------------------------------------
class WM_OT_REST(Operator):
bl_label = “REST”
bl_idname = “wm.rest”
bl_options={‘REGISTER’, ‘UNDO’}
bl_description = “Rests the Object Selected on Ground”
def execute(self, context):
scene = context.scene
for obj in context.selected_objects:
mx = obj.matrix_world
minz = min((mx @ v.co).z for v in obj.data.vertices)
mx.translation.z -= minz
return {'FINISHED'}
------------------------------------------------------------------------
CENTRE OBJECT
#---------------------------------------------------------
class WM_OT_CENTER(Operator):
bl_label = “CENTER”
bl_idname = “wm.center”
bl_description = “Centres the object on XYZ”
def execute(self, context):
scene = context.scene
bpy.context.object.location[0] = 0
bpy.context.object.location[1] = 0
bpy.context.object.location[2] = 0
return {'FINISHED'}
------------------------------------------------------------------------
CENTRE OBJECT MASS
#---------------------------------------------------------
class WM_OT_MASS(Operator):
bl_label = “MASS”
bl_idname = “wm.mass”
bl_description = “Centres object on XYZ and moves pivot to the mass orgin”
def execute(self, context):
scene = context.scene
bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS', center='MEDIAN')
bpy.context.object.location[0] = 0
bpy.context.object.location[1] = 0
bpy.context.object.location[2] = 0
return {'FINISHED'}