3D Pie menu: Support pivotbottom for selected objects #105105
@ -43,6 +43,22 @@ class PIE_OT_PivotToSelection(Operator):
|
|||||||
|
|
||||||
# Pivot to Bottom
|
# Pivot to Bottom
|
||||||
|
|
||||||
|
def origin_to_bottom(ob):
|
||||||
|
if ob.type != 'MESH':
|
||||||
|
return
|
||||||
|
|
||||||
|
init = 0
|
||||||
|
for x in ob.data.vertices:
|
||||||
|
if init == 0:
|
||||||
|
a = x.co.z
|
||||||
|
init = 1
|
||||||
|
elif x.co.z < a:
|
||||||
|
a = x.co.z
|
||||||
|
|
||||||
|
for x in ob.data.vertices:
|
||||||
|
x.co.z -= a
|
||||||
|
|
||||||
|
ob.location.z += a
|
||||||
|
|
||||||
class PIE_OT_PivotBottom(Operator):
|
class PIE_OT_PivotBottom(Operator):
|
||||||
bl_idname = "object.pivotobottom"
|
bl_idname = "object.pivotobottom"
|
||||||
@ -60,19 +76,8 @@ class PIE_OT_PivotBottom(Operator):
|
|||||||
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
|
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
|
||||||
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
|
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
|
||||||
|
|
||||||
init = 0
|
|
||||||
for ob in context.selected_objects:
|
for ob in context.selected_objects:
|
||||||
for x in ob.data.vertices:
|
origin_to_bottom(ob)
|
||||||
if init == 0:
|
|
||||||
a = x.co.z
|
|
||||||
init = 1
|
|
||||||
elif x.co.z < a:
|
|
||||||
a = x.co.z
|
|
||||||
|
|
||||||
for x in ob.data.vertices:
|
|
||||||
x.co.z -= a
|
|
||||||
|
|
||||||
ob.location.z += a
|
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
@ -94,19 +99,10 @@ class PIE_OT_PivotBottom_edit(Operator):
|
|||||||
bpy.ops.object.mode_set(mode='OBJECT')
|
bpy.ops.object.mode_set(mode='OBJECT')
|
||||||
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
|
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
|
||||||
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
|
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
|
||||||
o = context.active_object
|
|
||||||
init = 0
|
|
||||||
for x in o.data.vertices:
|
|
||||||
if init == 0:
|
|
||||||
a = x.co.z
|
|
||||||
init = 1
|
|
||||||
elif x.co.z < a:
|
|
||||||
a = x.co.z
|
|
||||||
|
|
||||||
for x in o.data.vertices:
|
for ob in context.selected_objects:
|
||||||
x.co.z -= a
|
origin_to_bottom(ob)
|
||||||
|
|
||||||
o.location.z += a
|
|
||||||
bpy.ops.object.mode_set(mode='EDIT')
|
bpy.ops.object.mode_set(mode='EDIT')
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
Loading…
Reference in New Issue
Block a user