diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-11-20 21:59:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-11-20 22:01:15 +0400 |
commit | 258c32a95672b532bd383fc6ca464127381ae651 (patch) | |
tree | 8a43f5ad6d6d9ede6ca719db80b5e4761da53929 /object_print3d_utils | |
parent | df1ee41c55a733c3a2e4241a4c154f49baf9c22e (diff) |
Fix T37555: Update 3D toolbox for changes to the BMesh API.
Diffstat (limited to 'object_print3d_utils')
-rw-r--r-- | object_print3d_utils/mesh_helpers.py | 9 | ||||
-rw-r--r-- | object_print3d_utils/operators.py | 11 |
2 files changed, 16 insertions, 4 deletions
diff --git a/object_print3d_utils/mesh_helpers.py b/object_print3d_utils/mesh_helpers.py index 4996ca69..450e2388 100644 --- a/object_print3d_utils/mesh_helpers.py +++ b/object_print3d_utils/mesh_helpers.py @@ -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 diff --git a/object_print3d_utils/operators.py b/object_print3d_utils/operators.py index 7548d165..7ebf5956 100644 --- a/object_print3d_utils/operators.py +++ b/object_print3d_utils/operators.py @@ -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 |