Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2017-09-02 20:42:43 +0300
committerMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2017-09-02 20:42:43 +0300
commit3eb4145a4cbfbd247dca3e3c1ff680b425ff2b02 (patch)
tree7103ede4a74887e31c9cb1ce3d40947069b234ff /object_print3d_utils
parent131ea02a4c0cc0c245c39488113fbe4b433afdee (diff)
Print3D Cleanup: Strict namanig for classes
Diffstat (limited to 'object_print3d_utils')
-rw-r--r--object_print3d_utils/__init__.py88
-rw-r--r--object_print3d_utils/operators.py52
-rw-r--r--object_print3d_utils/ui.py18
3 files changed, 76 insertions, 82 deletions
diff --git a/object_print3d_utils/__init__.py b/object_print3d_utils/__init__.py
index f665f54c..2ce219bb 100644
--- a/object_print3d_utils/__init__.py
+++ b/object_print3d_utils/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "3D Print Toolbox",
"author": "Campbell Barton",
- "blender": (2, 65, 0),
+ "blender": (2, 79, 0),
"location": "3D View > Toolbox",
"description": "Utilities for 3D printing",
"warning": "",
@@ -37,6 +37,8 @@ if "bpy" in locals():
importlib.reload(operators)
importlib.reload(mesh_helpers)
else:
+ import math
+
import bpy
from bpy.props import (
StringProperty,
@@ -49,15 +51,14 @@ else:
AddonPreferences,
PropertyGroup,
)
+
from . import (
ui,
operators,
)
-import math
-
-class Print3DSettings(PropertyGroup):
+class Print3D_Scene_Props(PropertyGroup):
export_format = EnumProperty(
name="Format",
description="Format type to export to",
@@ -101,7 +102,6 @@ class Print3DSettings(PropertyGroup):
name="Angle",
description="Limit for checking distorted faces",
subtype='ANGLE',
- default=math.radians(45.0),
min=0.0, max=math.radians(180.0),
)
angle_sharp = FloatProperty(
@@ -118,17 +118,14 @@ class Print3DSettings(PropertyGroup):
)
-# Add-ons Preferences Update Panel
-
-# Define Panel classes for updating
+# Panels for updating
panels = (
- ui.Print3DToolBarObject,
- ui.Print3DToolBarMesh,
+ ui.VIEW3D_PT_Print3D_Object,
+ ui.VIEW3D_PT_Print3D_Mesh,
)
-def update_panel(self, context):
- message = "3D Print Toolbox: Updating Panel locations has failed"
+def update_panels(self, context):
try:
for panel in panels:
if "bl_rna" in panel.__dict__:
@@ -139,61 +136,58 @@ def update_panel(self, context):
bpy.utils.register_class(panel)
except Exception as e:
+ message = "3D Print Toolbox: Updating Panel locations has failed"
print("\n[{}]\n{}\n\nError:\n{}".format(__name__, message, e))
- pass
-class printpreferences(AddonPreferences):
- # this must match the addon name, use '__package__'
- # when defining this in a submodule of a python package.
+class Print3D_Preferences(AddonPreferences):
bl_idname = __name__
category = StringProperty(
- name="Tab Category",
- description="Choose a name for the category of the panel",
- default="3D Printing",
- update=update_panel
- )
+ name="Tab Category",
+ description="Choose a name for the category of the panel",
+ default="3D Printing",
+ update=update_panels,
+ )
def draw(self, context):
layout = self.layout
- row = layout.row()
- col = row.column()
+ col = layout.column()
col.label(text="Tab Category:")
col.prop(self, "category", text="")
classes = (
- ui.Print3DToolBarObject,
- ui.Print3DToolBarMesh,
+ ui.VIEW3D_PT_Print3D_Object,
+ ui.VIEW3D_PT_Print3D_Mesh,
- operators.Print3DInfoVolume,
- operators.Print3DInfoArea,
+ operators.MESH_OT_Print3D_Info_Volume,
+ operators.MESH_OT_Print3D_Info_Area,
- operators.Print3DCheckDegenerate,
- operators.Print3DCheckDistorted,
- operators.Print3DCheckSolid,
- operators.Print3DCheckIntersections,
- operators.Print3DCheckThick,
- operators.Print3DCheckSharp,
- operators.Print3DCheckOverhang,
- operators.Print3DCheckAll,
+ operators.MESH_OT_Print3D_Check_Degenerate,
+ operators.MESH_OT_Print3D_Check_Distorted,
+ operators.MESH_OT_Print3D_Check_Solid,
+ operators.MESH_OT_Print3D_Check_Intersections,
+ operators.MESH_OT_Print3D_Check_Thick,
+ operators.MESH_OT_Print3D_Check_Sharp,
+ operators.MESH_OT_Print3D_Check_Overhang,
+ operators.MESH_OT_Print3D_Check_All,
- operators.Print3DCleanIsolated,
- operators.Print3DCleanDistorted,
- # operators.Print3DCleanThin,
- operators.Print3DCleanNonManifold,
+ operators.MESH_OT_Print3D_Clean_Isolated,
+ operators.MESH_OT_Print3D_Clean_Distorted,
+ # operators.MESH_OT_Print3D_Clean_Thin,
+ operators.MESH_OT_Print3D_Clean_Non_Manifold,
- operators.Print3DSelectReport,
+ operators.MESH_OT_Print3D_Select_Report,
- operators.Print3DScaleToVolume,
- operators.Print3DScaleToBounds,
+ operators.MESH_OT_Print3D_Scale_To_Volume,
+ operators.MESH_OT_Print3D_Scale_To_Bounds,
- operators.Print3DExport,
+ operators.MESH_OT_Print3D_Export,
- Print3DSettings,
- printpreferences,
+ Print3D_Scene_Props,
+ Print3D_Preferences,
)
@@ -201,9 +195,9 @@ def register():
for cls in classes:
bpy.utils.register_class(cls)
- bpy.types.Scene.print_3d = PointerProperty(type=Print3DSettings)
+ bpy.types.Scene.print_3d = PointerProperty(type=Print3D_Scene_Props)
- update_panel(None, bpy.context)
+ update_panels(None, bpy.context)
def unregister():
diff --git a/object_print3d_utils/operators.py b/object_print3d_utils/operators.py
index 01ef62cc..484e7bb9 100644
--- a/object_print3d_utils/operators.py
+++ b/object_print3d_utils/operators.py
@@ -48,7 +48,7 @@ def clean_float(text):
# Mesh Info
-class Print3DInfoVolume(Operator):
+class MESH_OT_Print3D_Info_Volume(Operator):
"""Report the volume of the active mesh"""
bl_idname = "mesh.print3d_info_volume"
bl_label = "Print3D Info Volume"
@@ -75,7 +75,7 @@ class Print3DInfoVolume(Operator):
return {'FINISHED'}
-class Print3DInfoArea(Operator):
+class MESH_OT_Print3D_Info_Area(Operator):
"""Report the surface area of the active mesh"""
bl_idname = "mesh.print3d_info_area"
bl_label = "Print3D Info Area"
@@ -122,7 +122,7 @@ def multiple_obj_warning(self, context):
self.report({"INFO"}, "Multiple selected objects. Only the active one will be evaluated")
-class Print3DCheckSolid(Operator):
+class MESH_OT_Print3D_Check_Solid(Operator):
"""Check for geometry is solid (has valid inside/outside) and correct normals"""
bl_idname = "mesh.print3d_check_solid"
bl_label = "Print3D Check Solid"
@@ -150,7 +150,7 @@ class Print3DCheckSolid(Operator):
return execute_check(self, context)
-class Print3DCheckIntersections(Operator):
+class MESH_OT_Print3D_Check_Intersections(Operator):
"""Check geometry for self intersections"""
bl_idname = "mesh.print3d_check_intersect"
bl_label = "Print3D Check Intersections"
@@ -165,7 +165,7 @@ class Print3DCheckIntersections(Operator):
return execute_check(self, context)
-class Print3DCheckDegenerate(Operator):
+class MESH_OT_Print3D_Check_Degenerate(Operator):
"""Check for degenerate geometry that may not print properly """ \
"""(zero area faces, zero length edges)"""
bl_idname = "mesh.print3d_check_degenerate"
@@ -195,7 +195,7 @@ class Print3DCheckDegenerate(Operator):
return execute_check(self, context)
-class Print3DCheckDistorted(Operator):
+class MESH_OT_Print3D_Check_Distorted(Operator):
"""Check for non-flat faces """
bl_idname = "mesh.print3d_check_distort"
bl_label = "Print3D Check Distorted Faces"
@@ -233,7 +233,7 @@ class Print3DCheckDistorted(Operator):
return execute_check(self, context)
-class Print3DCheckThick(Operator):
+class MESH_OT_Print3D_Check_Thick(Operator):
"""Check geometry is above the minimum thickness preference """ \
"""(relies on correct normals)"""
bl_idname = "mesh.print3d_check_thick"
@@ -253,7 +253,7 @@ class Print3DCheckThick(Operator):
return execute_check(self, context)
-class Print3DCheckSharp(Operator):
+class MESH_OT_Print3D_Check_Sharp(Operator):
"""Check edges are below the sharpness preference"""
bl_idname = "mesh.print3d_check_sharp"
bl_label = "Print3D Check Sharp"
@@ -278,7 +278,7 @@ class Print3DCheckSharp(Operator):
return execute_check(self, context)
-class Print3DCheckOverhang(Operator):
+class MESH_OT_Print3D_Check_Overhang(Operator):
"""Check faces don't overhang past a certain angle"""
bl_idname = "mesh.print3d_check_overhang"
bl_label = "Print3D Check Overhang"
@@ -314,19 +314,19 @@ class Print3DCheckOverhang(Operator):
return execute_check(self, context)
-class Print3DCheckAll(Operator):
+class MESH_OT_Print3D_Check_All(Operator):
"""Run all checks"""
bl_idname = "mesh.print3d_check_all"
bl_label = "Print3D Check All"
check_cls = (
- Print3DCheckSolid,
- Print3DCheckIntersections,
- Print3DCheckDegenerate,
- Print3DCheckDistorted,
- Print3DCheckThick,
- Print3DCheckSharp,
- Print3DCheckOverhang,
+ MESH_OT_Print3D_Check_Solid,
+ MESH_OT_Print3D_Check_Intersections,
+ MESH_OT_Print3D_Check_Degenerate,
+ MESH_OT_Print3D_Check_Distorted,
+ MESH_OT_Print3D_Check_Thick,
+ MESH_OT_Print3D_Check_Sharp,
+ MESH_OT_Print3D_Check_Overhang,
)
def execute(self, context):
@@ -343,7 +343,7 @@ class Print3DCheckAll(Operator):
return {'FINISHED'}
-class Print3DCleanIsolated(Operator):
+class MESH_OT_Print3D_Clean_Isolated(Operator):
"""Cleanup isolated vertices and edges"""
bl_idname = "mesh.print3d_clean_isolated"
bl_label = "Print3D Clean Isolated "
@@ -407,7 +407,7 @@ class Print3DCleanIsolated(Operator):
return {'CANCELLED'}
-class Print3DCleanDistorted(Operator):
+class MESH_OT_Print3D_Clean_Distorted(Operator):
"""Tessellate distorted faces"""
bl_idname = "mesh.print3d_clean_distorted"
bl_label = "Print3D Clean Distorted"
@@ -440,7 +440,7 @@ class Print3DCleanDistorted(Operator):
return {'CANCELLED'}
-class Print3DCleanNonManifold(Operator):
+class MESH_OT_Print3D_Clean_Non_Manifold(Operator):
"""Cleanup problems, like holes, non-manifold vertices, and inverted normals"""
bl_idname = "mesh.print3d_clean_non_manifold"
bl_label = "Print3D Clean Non-Manifold and Inverted"
@@ -594,7 +594,7 @@ class Print3DCleanNonManifold(Operator):
bpy.ops.mesh.delete(type='VERT')
-class Print3DCleanThin(Operator):
+class MESH_OT_Print3D_Clean_Thin(Operator):
"""Ensure minimum thickness"""
bl_idname = "mesh.print3d_clean_thin"
bl_label = "Print3D Clean Thin"
@@ -610,7 +610,7 @@ class Print3DCleanThin(Operator):
# Select Report
# ... helper function for info UI
-class Print3DSelectReport(Operator):
+class MESH_OT_Print3D_Select_Report(Operator):
"""Select the data associated with this report"""
bl_idname = "mesh.print3d_select_report"
bl_label = "Print3D Select Report"
@@ -641,7 +641,7 @@ class Print3DSelectReport(Operator):
bpy.ops.mesh.select_mode(type=self._type_to_mode[bm_type])
bm = bmesh.from_edit_mesh(obj.data)
- elems = getattr(bm, Print3DSelectReport._type_to_attr[bm_type])[:]
+ elems = getattr(bm, MESH_OT_Print3D_Select_Report._type_to_attr[bm_type])[:]
try:
for i in bm_array:
@@ -669,7 +669,7 @@ def _scale(scale, report=None, report_suffix=""):
report({'INFO'}, "Scaled by %s%s" % (clean_float("%.6f" % scale), report_suffix))
-class Print3DScaleToVolume(Operator):
+class MESH_OT_Print3D_Scale_To_Volume(Operator):
"""Scale edit-mesh or selected-objects to a set volume"""
bl_idname = "mesh.print3d_scale_to_volume"
bl_label = "Scale to Volume"
@@ -715,7 +715,7 @@ class Print3DScaleToVolume(Operator):
return wm.invoke_props_dialog(self)
-class Print3DScaleToBounds(Operator):
+class MESH_OT_Print3D_Scale_To_Bounds(Operator):
"""Scale edit-mesh or selected-objects to fit within a maximum length"""
bl_idname = "mesh.print3d_scale_to_bounds"
bl_label = "Scale to Bounds"
@@ -769,7 +769,7 @@ class Print3DScaleToBounds(Operator):
# ------
# Export
-class Print3DExport(Operator):
+class MESH_OT_Print3D_Export(Operator):
"""Export active object using print3d settings"""
bl_idname = "mesh.print3d_export"
bl_label = "Print3D Export"
diff --git a/object_print3d_utils/ui.py b/object_print3d_utils/ui.py
index dd286557..cad43d1c 100644
--- a/object_print3d_utils/ui.py
+++ b/object_print3d_utils/ui.py
@@ -20,12 +20,12 @@
# Interface for this addon.
-import bmesh
from bpy.types import Panel
+import bmesh
from . import report
-class Print3DToolBar:
+class Print3D_ToolBar:
bl_label = "Print3D"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
@@ -39,7 +39,7 @@ class Print3DToolBar:
@classmethod
def poll(cls, context):
obj = context.active_object
- return obj and obj.type == 'MESH' and context.mode in {'OBJECT','EDIT_MESH'}
+ return obj and obj.type == 'MESH'
@staticmethod
def draw_report(layout, context):
@@ -57,7 +57,7 @@ class Print3DToolBar:
bm_type, bm_array = data
col.operator("mesh.print3d_select_report",
text=text,
- icon=Print3DToolBar._type_to_icon[bm_type]).index = i
+ icon=Print3D_ToolBar._type_to_icon[bm_type]).index = i
layout.operator("mesh.select_non_manifold", text='Non Manifold Extended')
else:
col.label(text)
@@ -130,17 +130,17 @@ class Print3DToolBar:
rowsub.prop(print_3d, "export_format", text="")
rowsub.operator("mesh.print3d_export", text="Export", icon='EXPORT')
- Print3DToolBar.draw_report(layout, context)
+ Print3D_ToolBar.draw_report(layout, context)
# So we can have a panel in both object mode and editmode
-class Print3DToolBarObject(Panel, Print3DToolBar):
+class VIEW3D_PT_Print3D_Object(Panel, Print3D_ToolBar):
bl_category = "3D Printing"
- bl_idname = "MESH_PT_print3d_object"
+ bl_idname = "VIEW3D_PT_print3d_object"
bl_context = "objectmode"
-class Print3DToolBarMesh(Panel, Print3DToolBar):
+class VIEW3D_PT_Print3D_Mesh(Panel, Print3D_ToolBar):
bl_category = "3D Printing"
- bl_idname = "MESH_PT_print3d_mesh"
+ bl_idname = "VIEW3D_PT_print3d_mesh"
bl_context = "mesh_edit"