Changeset View
Changeset View
Standalone View
Standalone View
object_print3d_utils/__init__.py
| Show All 15 Lines | |||||
| # | # | ||||
| # ##### END GPL LICENSE BLOCK ##### | # ##### END GPL LICENSE BLOCK ##### | ||||
| # <pep8 compliant> | # <pep8 compliant> | ||||
| bl_info = { | bl_info = { | ||||
| "name": "3D Print Toolbox", | "name": "3D Print Toolbox", | ||||
| "author": "Campbell Barton", | "author": "Campbell Barton", | ||||
| "blender": (2, 79, 0), | "blender": (2, 80, 0), | ||||
| "location": "3D View > Toolbox", | "location": "3D View > Toolbox", | ||||
| "description": "Utilities for 3D printing", | "description": "Utilities for 3D printing", | ||||
| "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/" | "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/" | ||||
| "Scripts/Modeling/PrintToolbox", | "Scripts/Modeling/PrintToolbox", | ||||
| "support": 'OFFICIAL', | "support": 'OFFICIAL', | ||||
| "category": "Mesh", | "category": "Mesh", | ||||
| } | } | ||||
| Show All 21 Lines | else: | ||||
| from . import ( | from . import ( | ||||
| ui, | ui, | ||||
| operators, | operators, | ||||
| ) | ) | ||||
| class Print3D_Scene_Props(PropertyGroup): | class Print3D_Scene_Props(PropertyGroup): | ||||
| export_format = EnumProperty( | export_format: EnumProperty( | ||||
| name="Format", | name="Format", | ||||
| description="Format type to export to", | description="Format type to export to", | ||||
| items=(('STL', "STL", ""), | items=( | ||||
| ('STL', "STL", ""), | |||||
| ('PLY', "PLY", ""), | ('PLY', "PLY", ""), | ||||
| ('WRL', "VRML2", ""), | ('WRL', "VRML2", ""), | ||||
| ('X3D', "X3D", ""), | ('X3D', "X3D", ""), | ||||
| ('OBJ', "OBJ", "")), | ('OBJ', "OBJ", ""), | ||||
| ), | |||||
| default='STL', | default='STL', | ||||
| ) | ) | ||||
| use_export_texture = BoolProperty( | use_export_texture: BoolProperty( | ||||
| name="Copy Textures", | name="Copy Textures", | ||||
| description="Copy textures on export to the output path", | description="Copy textures on export to the output path", | ||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| use_apply_scale = BoolProperty( | use_apply_scale: BoolProperty( | ||||
| name="Apply Scale", | name="Apply Scale", | ||||
| description="Apply scene scale setting on export", | description="Apply scene scale setting on export", | ||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| export_path = StringProperty( | export_path: StringProperty( | ||||
| name="Export Directory", | name="Export Directory", | ||||
| description="Path to directory where the files are created", | description="Path to directory where the files are created", | ||||
| default="//", maxlen=1024, subtype="DIR_PATH", | default="//", maxlen=1024, subtype="DIR_PATH", | ||||
| ) | ) | ||||
| thickness_min = FloatProperty( | thickness_min: FloatProperty( | ||||
| name="Thickness", | name="Thickness", | ||||
| description="Minimum thickness", | description="Minimum thickness", | ||||
| subtype='DISTANCE', | subtype='DISTANCE', | ||||
| default=0.001, # 1mm | default=0.001, # 1mm | ||||
| min=0.0, max=10.0, | min=0.0, max=10.0, | ||||
| ) | ) | ||||
| threshold_zero = FloatProperty( | threshold_zero: FloatProperty( | ||||
| name="Threshold", | name="Threshold", | ||||
| description="Limit for checking zero area/length", | description="Limit for checking zero area/length", | ||||
| default=0.0001, | default=0.0001, | ||||
| precision=5, | precision=5, | ||||
| min=0.0, max=0.2, | min=0.0, max=0.2, | ||||
| ) | ) | ||||
| angle_distort = FloatProperty( | angle_distort: FloatProperty( | ||||
| name="Angle", | name="Angle", | ||||
| description="Limit for checking distorted faces", | description="Limit for checking distorted faces", | ||||
| subtype='ANGLE', | subtype='ANGLE', | ||||
| default=math.radians(45.0), | default=math.radians(45.0), | ||||
| min=0.0, max=math.radians(180.0), | min=0.0, max=math.radians(180.0), | ||||
| ) | ) | ||||
| angle_sharp = FloatProperty( | angle_sharp: FloatProperty( | ||||
| name="Angle", | name="Angle", | ||||
| subtype='ANGLE', | subtype='ANGLE', | ||||
| default=math.radians(160.0), | default=math.radians(160.0), | ||||
| min=0.0, max=math.radians(180.0), | min=0.0, max=math.radians(180.0), | ||||
| ) | ) | ||||
| angle_overhang = FloatProperty( | angle_overhang: FloatProperty( | ||||
| name="Angle", | name="Angle", | ||||
| subtype='ANGLE', | subtype='ANGLE', | ||||
| default=math.radians(45.0), | default=math.radians(45.0), | ||||
| min=0.0, max=math.radians(90.0), | min=0.0, max=math.radians(90.0), | ||||
| ) | ) | ||||
| # Update panel category name | |||||
| panels = ( | |||||
| ui.VIEW3D_PT_Print3D_Object, | |||||
| ui.VIEW3D_PT_Print3D_Mesh, | |||||
| ) | |||||
| def update_panels(self, context): | |||||
| try: | |||||
| for panel in panels: | |||||
| if "bl_rna" in panel.__dict__: | |||||
| bpy.utils.unregister_class(panel) | |||||
| for panel in panels: | |||||
| panel.bl_category = context.user_preferences.addons[__name__].preferences.category | |||||
| 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)) | |||||
| 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_panels, | |||||
| ) | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| layout.prop(self, "category") | |||||
| classes = ( | classes = ( | ||||
| ui.VIEW3D_PT_Print3D_Object, | ui.VIEW3D_PT_Print3D_Object, | ||||
| ui.VIEW3D_PT_Print3D_Mesh, | ui.VIEW3D_PT_Print3D_Mesh, | ||||
| operators.MESH_OT_Print3D_Info_Volume, | operators.MESH_OT_Print3D_Info_Volume, | ||||
| operators.MESH_OT_Print3D_Info_Area, | operators.MESH_OT_Print3D_Info_Area, | ||||
| operators.MESH_OT_Print3D_Check_Degenerate, | operators.MESH_OT_Print3D_Check_Degenerate, | ||||
| Show All 13 Lines | classes = ( | ||||
| operators.MESH_OT_Print3D_Select_Report, | operators.MESH_OT_Print3D_Select_Report, | ||||
| operators.MESH_OT_Print3D_Scale_To_Volume, | operators.MESH_OT_Print3D_Scale_To_Volume, | ||||
| operators.MESH_OT_Print3D_Scale_To_Bounds, | operators.MESH_OT_Print3D_Scale_To_Bounds, | ||||
| operators.MESH_OT_Print3D_Export, | operators.MESH_OT_Print3D_Export, | ||||
| Print3D_Scene_Props, | Print3D_Scene_Props, | ||||
| Print3D_Preferences, | |||||
| ) | ) | ||||
| def register(): | def register(): | ||||
| for cls in classes: | for cls in classes: | ||||
| bpy.utils.register_class(cls) | bpy.utils.register_class(cls) | ||||
| bpy.types.Scene.print_3d = PointerProperty(type=Print3D_Scene_Props) | bpy.types.Scene.print_3d = PointerProperty(type=Print3D_Scene_Props) | ||||
| update_panels(None, bpy.context) | |||||
| def unregister(): | def unregister(): | ||||
| for cls in classes: | for cls in classes: | ||||
| bpy.utils.unregister_class(cls) | bpy.utils.unregister_class(cls) | ||||
| del bpy.types.Scene.print_3d | del bpy.types.Scene.print_3d | ||||