diff options
author | lijenstina <lijenstina@gmail.com> | 2016-11-12 17:55:34 +0300 |
---|---|---|
committer | lijenstina <lijenstina@gmail.com> | 2016-11-12 17:55:34 +0300 |
commit | 3b9cbaa44efb03e768219edb2d0427d478233691 (patch) | |
tree | f01ae3b8318286536912e1d23ec1702efc28f9f1 /object_print3d_utils | |
parent | 7df41339ae89c3281cb8d81f0b9d09c11aa266ae (diff) |
Print3D: cleanup unused variables and imports, fix unused operator
Pep8 cleanup
Remove unused variables and imports
Print3DCleanThin was registered even though it was just a stub
It would crash when called from the search menu
(TODO was not commented out)
Added an info message about multiple object selection - only the active
object is checked
Diffstat (limited to 'object_print3d_utils')
-rw-r--r-- | object_print3d_utils/__init__.py | 12 | ||||
-rw-r--r-- | object_print3d_utils/mesh_helpers.py | 6 | ||||
-rw-r--r-- | object_print3d_utils/operators.py | 22 | ||||
-rw-r--r-- | object_print3d_utils/report.py | 2 | ||||
-rw-r--r-- | object_print3d_utils/ui.py | 4 |
5 files changed, 25 insertions, 21 deletions
diff --git a/object_print3d_utils/__init__.py b/object_print3d_utils/__init__.py index 60c903c5..5cf1ec53 100644 --- a/object_print3d_utils/__init__.py +++ b/object_print3d_utils/__init__.py @@ -41,14 +41,11 @@ else: from bpy.props import ( StringProperty, BoolProperty, - IntProperty, FloatProperty, - FloatVectorProperty, EnumProperty, PointerProperty, ) from bpy.types import ( - Operator, AddonPreferences, PropertyGroup, ) @@ -59,6 +56,7 @@ else: import math + class Print3DSettings(PropertyGroup): export_format = EnumProperty( name="Format", @@ -120,7 +118,7 @@ class Print3DSettings(PropertyGroup): ) -## Addons Preferences Update Panel +# Addons Preferences Update Panel def update_panel(self, context): try: bpy.utils.unregister_class(ui.Print3DToolBarObject) @@ -132,7 +130,8 @@ def update_panel(self, context): ui.Print3DToolBarMesh.bl_category = context.user_preferences.addons[__name__].preferences.category bpy.utils.register_class(ui.Print3DToolBarMesh) -class printpreferences(bpy.types.AddonPreferences): + +class printpreferences(AddonPreferences): # this must match the addon name, use '__package__' # when defining this in a submodule of a python package. bl_idname = __name__ @@ -151,6 +150,7 @@ class printpreferences(bpy.types.AddonPreferences): col.label(text="Tab Category:") col.prop(self, "category", text="") + classes = ( ui.Print3DToolBarObject, ui.Print3DToolBarMesh, @@ -169,7 +169,7 @@ classes = ( operators.Print3DCleanIsolated, operators.Print3DCleanDistorted, - operators.Print3DCleanThin, + # operators.Print3DCleanThin, operators.Print3DCleanNonManifold, operators.Print3DSelectReport, diff --git a/object_print3d_utils/mesh_helpers.py b/object_print3d_utils/mesh_helpers.py index 84d5ac74..ca6e0716 100644 --- a/object_print3d_utils/mesh_helpers.py +++ b/object_print3d_utils/mesh_helpers.py @@ -214,7 +214,6 @@ def bmesh_check_thick_object(obj, thickness): return array.array('i', faces_error) - def object_merge(context, objects): """ Caller must remove. @@ -271,8 +270,8 @@ def object_merge(context, objects): del base_new, obj_new # remove object and its mesh, join does this - #~ scene.objects.unlink(obj_new) - #~ bpy.data.objects.remove(obj_new) + # scene.objects.unlink(obj_new) + # bpy.data.objects.remove(obj_new) bpy.data.meshes.remove(mesh_new) @@ -280,4 +279,3 @@ def object_merge(context, objects): # return new object return base_base - diff --git a/object_print3d_utils/operators.py b/object_print3d_utils/operators.py index 0ede00df..47d1f58b 100644 --- a/object_print3d_utils/operators.py +++ b/object_print3d_utils/operators.py @@ -24,13 +24,8 @@ import bpy import bmesh from bpy.types import Operator from bpy.props import ( - StringProperty, - BoolProperty, IntProperty, FloatProperty, - FloatVectorProperty, - EnumProperty, - PointerProperty, ) from . import ( @@ -102,7 +97,7 @@ class Print3DInfoArea(Operator): info.append(("Area: %s \"²" % clean_float("%.4f" % ((area * (scale ** 2.0)) / (0.0254 ** 2.0))), None)) else: info.append(("Area: %s²" % clean_float("%.8f" % area), None)) - + report.update(*info) return {'FINISHED'} @@ -117,9 +112,16 @@ def execute_check(self, context): self.main_check(obj, info) report.update(*info) + multiple_obj_warning(self, context) + return {'FINISHED'} +def multiple_obj_warning(self, context): + if len(context.selected_objects) > 1: + self.report({"INFO"}, "Multiple selected objects. Only the active one will be evaluated") + + class Print3DCheckSolid(Operator): """Check for geometry is solid (has valid inside/outside) and correct normals""" bl_idname = "mesh.print3d_check_solid" @@ -333,6 +335,8 @@ class Print3DCheckAll(Operator): report.update(*info) + multiple_obj_warning(self, context) + return {'FINISHED'} @@ -594,7 +598,7 @@ class Print3DCleanThin(Operator): bl_options = {'REGISTER', 'UNDO'} def execute(self, context): - TODO + # TODO return {'FINISHED'} @@ -644,7 +648,7 @@ class Print3DSelectReport(Operator): self.report({'WARNING'}, "Report is out of date, re-run check") # cool, but in fact annoying - #~ bpy.ops.view3d.view_selected(use_all_regions=False) + # bpy.ops.view3d.view_selected(use_all_regions=False) return {'FINISHED'} @@ -768,8 +772,6 @@ class Print3DExport(Operator): bl_label = "Print3D Export" def execute(self, context): - scene = bpy.context.scene - print_3d = scene.print_3d from . import export info = [] diff --git a/object_print3d_utils/report.py b/object_print3d_utils/report.py index a27986f0..511c5e42 100644 --- a/object_print3d_utils/report.py +++ b/object_print3d_utils/report.py @@ -23,8 +23,10 @@ _data = [] + def update(*args): _data[:] = args + def info(): return tuple(_data) diff --git a/object_print3d_utils/ui.py b/object_print3d_utils/ui.py index 2bcf4d55..c556df69 100644 --- a/object_print3d_utils/ui.py +++ b/object_print3d_utils/ui.py @@ -24,6 +24,7 @@ import bmesh from bpy.types import Panel from . import report + class Print3DToolBar: bl_label = "Print3D" bl_space_type = 'VIEW_3D' @@ -65,7 +66,6 @@ class Print3DToolBar: scene = context.scene print_3d = scene.print_3d - obj = context.object # TODO, presets @@ -130,12 +130,14 @@ class Print3DToolBar: Print3DToolBar.draw_report(layout, context) + # So we can have a panel in both object mode and editmode class Print3DToolBarObject(Panel, Print3DToolBar): bl_category = "3D Printing" bl_idname = "MESH_PT_print3d_object" bl_context = "objectmode" + class Print3DToolBarMesh(Panel, Print3DToolBar): bl_category = "3D Printing" bl_idname = "MESH_PT_print3d_mesh" |