Rework: Origins Pie #6
@ -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':
|
||||
|
Loading…
Reference in New Issue
Block a user