Rework: Origins Pie #6

Merged
Demeter Dzadik merged 2 commits from origins-pie-rework into main 2024-08-21 02:31:22 +02:00
Showing only changes of commit 8209bdc19b - Show all commits

View File

@ -63,14 +63,18 @@ class PIE_OT_set_origin_to_bottom(Operator):
org_mode = obj.mode
if obj.type == 'MESH':
bpy.ops.object.mode_set(mode='OBJECT')
min_z = min([v.co.z for v in obj.data.vertices])
elif obj.type == 'ARMATURE':
context.view_layer.objects.active = obj
bpy.ops.object.mode_set(mode='EDIT')
min_z = min([min([bone.head.z, bone.tail.z]) for bone in obj.data.edit_bones])
else:
try:
if obj.type == 'MESH':
bpy.ops.object.mode_set(mode='OBJECT')
min_z = min([v.co.z for v in obj.data.vertices])
elif obj.type == 'ARMATURE':
context.view_layer.objects.active = obj
bpy.ops.object.mode_set(mode='EDIT')
min_z = min([min([bone.head.z, bone.tail.z]) for bone in obj.data.edit_bones])
else:
return False
except ValueError:
# min([]) would result in this error, so if the object is empty.
return False
if obj.type == 'MESH':