diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-07 04:12:13 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-07 04:12:13 +0400 |
commit | 4a9eba45170c7fdb6c78906340769ba6355dc495 (patch) | |
tree | f645e7c1ffdbfba463814b90e5db2406d0a1467d /object_print3d_utils/operators.py | |
parent | 5009787d61ec9fb6e056f86deedca6844bbb3d6a (diff) |
use bmesh volume function, show cubit inches for volume/area statistics.
Diffstat (limited to 'object_print3d_utils/operators.py')
-rw-r--r-- | object_print3d_utils/operators.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/object_print3d_utils/operators.py b/object_print3d_utils/operators.py index 8db7f429..7548d165 100644 --- a/object_print3d_utils/operators.py +++ b/object_print3d_utils/operators.py @@ -62,14 +62,18 @@ class Print3DInfoVolume(Operator): obj = context.active_object bm = mesh_helpers.bmesh_copy_from_object(obj, apply_modifiers=True) - volume = mesh_helpers.bmesh_calc_volume(bm) + volume = bm.calc_volume() bm.free() info = [] - info.append(("Volume: %s³" % clean_float("%.4f" % volume), - None)) - info.append(("%s cm³" % clean_float("%.4f" % ((volume * (scale * scale * scale)) / (0.01 * 0.01 * 0.01))), + info.append(("Volume: %s³" % clean_float("%.8f" % volume), None)) + if unit.system == 'IMPERIAL': + info.append(("%s \"³" % clean_float("%.4f" % ((volume * (scale * scale * scale)) / (0.0254 * 0.0254 * 0.0254))), + None)) + else: + info.append(("%s cm³" % clean_float("%.4f" % ((volume * (scale * scale * scale)) / (0.01 * 0.01 * 0.01))), + None)) report.update(*info) return {'FINISHED'} @@ -91,10 +95,14 @@ class Print3DInfoArea(Operator): bm.free() info = [] - info.append(("Area: %s²" % clean_float("%.4f" % area), - None)) - info.append(("%s cm²" % clean_float("%.4f" % ((area * (scale * scale)) / (0.01 * 0.01))), + info.append(("Area: %s²" % clean_float("%.8f" % area), None)) + if unit.system == 'IMPERIAL': + info.append(("%s \"²" % clean_float("%.4f" % ((area * (scale * scale)) / (0.0254 * 0.0254))), + None)) + else: + info.append(("%s cm²" % clean_float("%.4f" % ((area * (scale * scale)) / (0.01 * 0.01))), + None)) report.update(*info) return {'FINISHED'} @@ -525,7 +533,7 @@ class Print3DScaleToVolume(Operator): def calc_volume(obj): bm = mesh_helpers.bmesh_copy_from_object(obj, apply_modifiers=True) - volume = mesh_helpers.bmesh_calc_volume_signed(bm) + volume = bm.calc_volume(signed=True) bm.free() return volume |