Fix T37555: Update 3D toolbox for changes to the BMesh API.
This commit is contained in:
parent
df1ee41c55
commit
258c32a956
Notes:
blender-bot
2023-02-14 20:13:07 +01:00
Referenced by issue #37555, 3D Print Toolbox Error message
|
@ -54,7 +54,7 @@ def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifier
|
|||
bm.transform(obj.matrix_world)
|
||||
|
||||
if triangulate:
|
||||
bmesh.ops.triangulate(bm, faces=bm.faces, use_beauty=True)
|
||||
bmesh.ops.triangulate(bm, faces=bm.faces)
|
||||
|
||||
return bm
|
||||
|
||||
|
@ -103,6 +103,9 @@ def bmesh_check_self_intersect_object(obj):
|
|||
"""
|
||||
import bpy
|
||||
|
||||
if not obj.data.polygons:
|
||||
return array.array('i', ())
|
||||
|
||||
# Heres what we do!
|
||||
#
|
||||
# * Take original Mesh.
|
||||
|
@ -115,7 +118,7 @@ def bmesh_check_self_intersect_object(obj):
|
|||
# Triangulate
|
||||
bm = bmesh_copy_from_object(obj, transform=False, triangulate=False)
|
||||
face_map_index_org = {f: i for i, f in enumerate(bm.faces)}
|
||||
ret = bmesh.ops.triangulate(bm, faces=bm.faces, use_beauty=False)
|
||||
ret = bmesh.ops.triangulate(bm, faces=bm.faces)
|
||||
face_map = ret["face_map"]
|
||||
# map new index to original index
|
||||
face_map_index = {i: face_map_index_org[face_map.get(f, f)] for i, f in enumerate(bm.faces)}
|
||||
|
@ -196,7 +199,7 @@ def bmesh_check_thick_object(obj, thickness):
|
|||
bm = bmesh_copy_from_object(obj, transform=True, triangulate=False)
|
||||
# map original faces to their index.
|
||||
face_index_map_org = {f: i for i, f in enumerate(bm.faces)}
|
||||
ret = bmesh.ops.triangulate(bm, faces=bm.faces, use_beauty=False)
|
||||
ret = bmesh.ops.triangulate(bm, faces=bm.faces)
|
||||
face_map = ret["face_map"]
|
||||
del ret
|
||||
# old edge -> new mapping
|
||||
|
|
|
@ -543,6 +543,10 @@ class Print3DScaleToVolume(Operator):
|
|||
volume = sum(calc_volume(obj) for obj in context.selected_editable_objects
|
||||
if obj.type == 'MESH')
|
||||
|
||||
if volume == 0.0:
|
||||
self.report({'WARNING'}, "Object has zero volume")
|
||||
return {'CANCELLED'}
|
||||
|
||||
self.volume_init = self.volume = abs(volume)
|
||||
|
||||
wm = context.window_manager
|
||||
|
@ -582,12 +586,17 @@ class Print3DScaleToBounds(Operator):
|
|||
|
||||
if context.mode == 'EDIT_MESH':
|
||||
length, axis = calc_length([Vector(v) * obj.matrix_world
|
||||
for v in context.edit_object.bound_box])
|
||||
for obj in [context.edit_object]
|
||||
for v in obj.bound_box])
|
||||
else:
|
||||
length, axis = calc_length([Vector(v) * obj.matrix_world
|
||||
for obj in context.selected_editable_objects
|
||||
if obj.type == 'MESH' for v in obj.bound_box])
|
||||
|
||||
if length == 0.0:
|
||||
self.report({'WARNING'}, "Object has zero bounds")
|
||||
return {'CANCELLED'}
|
||||
|
||||
self.length_init = self.length = length
|
||||
self.axis_init = axis
|
||||
|
||||
|
|
Loading…
Reference in New Issue