Update scripts to account for removal of the context override to bpy.ops
[blender-addons.git] / object_print3d_utils / __init__.py
blob9ce0a1322271c69ba81a707b5e199fbc4ec231bf
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 bl_info = {
4 "name": "3D-Print Toolbox",
5 "author": "Campbell Barton",
6 "blender": (3, 6, 0),
7 "location": "3D View > Sidebar",
8 "description": "Utilities for 3D printing",
9 "doc_url": "{BLENDER_MANUAL_URL}/addons/mesh/3d_print_toolbox.html",
10 "support": 'OFFICIAL',
11 "category": "Mesh",
15 if "bpy" in locals():
16 import importlib
17 importlib.reload(ui)
18 importlib.reload(operators)
19 if "mesh_helpers" in locals():
20 importlib.reload(mesh_helpers)
21 if "export" in locals():
22 importlib.reload(export)
23 else:
24 import math
26 import bpy
27 from bpy.types import PropertyGroup
28 from bpy.props import (
29 StringProperty,
30 BoolProperty,
31 FloatProperty,
32 EnumProperty,
33 PointerProperty,
36 from . import (
37 ui,
38 operators,
42 class SceneProperties(PropertyGroup):
43 use_alignxy_face_area: BoolProperty(
44 name="Face Areas",
45 description="Normalize normals proportional to face areas",
46 default=False,
49 export_format: EnumProperty(
50 name="Format",
51 description="Format type to export to",
52 items=(
53 ('OBJ', "OBJ", ""),
54 ('PLY', "PLY", ""),
55 ('STL', "STL", ""),
56 ('X3D', "X3D", ""),
58 default='STL',
60 use_export_texture: BoolProperty(
61 name="Copy Textures",
62 description="Copy textures on export to the output path",
63 default=False,
65 use_apply_scale: BoolProperty(
66 name="Apply Scale",
67 description="Apply scene scale setting on export",
68 default=False,
70 use_data_layers: BoolProperty(
71 name="Data Layers",
72 description=(
73 "Export normals, UVs, vertex colors and materials for formats that support it "
74 "significantly increasing file size"
77 export_path: StringProperty(
78 name="Export Directory",
79 description="Path to directory where the files are created",
80 default="//",
81 maxlen=1024,
82 subtype="DIR_PATH",
84 thickness_min: FloatProperty(
85 name="Thickness",
86 description="Minimum thickness",
87 subtype='DISTANCE',
88 default=0.001, # 1mm
89 min=0.0,
90 max=10.0,
92 threshold_zero: FloatProperty(
93 name="Threshold",
94 description="Limit for checking zero area/length",
95 default=0.0001,
96 precision=5,
97 min=0.0,
98 max=0.2,
100 angle_distort: FloatProperty(
101 name="Angle",
102 description="Limit for checking distorted faces",
103 subtype='ANGLE',
104 default=math.radians(45.0),
105 min=0.0,
106 max=math.radians(180.0),
108 angle_sharp: FloatProperty(
109 name="Angle",
110 subtype='ANGLE',
111 default=math.radians(160.0),
112 min=0.0,
113 max=math.radians(180.0),
115 angle_overhang: FloatProperty(
116 name="Angle",
117 subtype='ANGLE',
118 default=math.radians(45.0),
119 min=0.0,
120 max=math.radians(90.0),
124 classes = (
125 SceneProperties,
127 ui.VIEW3D_PT_print3d_analyze,
128 ui.VIEW3D_PT_print3d_cleanup,
129 ui.VIEW3D_PT_print3d_transform,
130 ui.VIEW3D_PT_print3d_export,
132 operators.MESH_OT_print3d_info_volume,
133 operators.MESH_OT_print3d_info_area,
134 operators.MESH_OT_print3d_check_degenerate,
135 operators.MESH_OT_print3d_check_distorted,
136 operators.MESH_OT_print3d_check_solid,
137 operators.MESH_OT_print3d_check_intersections,
138 operators.MESH_OT_print3d_check_thick,
139 operators.MESH_OT_print3d_check_sharp,
140 operators.MESH_OT_print3d_check_overhang,
141 operators.MESH_OT_print3d_check_all,
142 operators.MESH_OT_print3d_clean_distorted,
143 # operators.MESH_OT_print3d_clean_thin,
144 operators.MESH_OT_print3d_clean_non_manifold,
145 operators.MESH_OT_print3d_select_report,
146 operators.MESH_OT_print3d_scale_to_volume,
147 operators.MESH_OT_print3d_scale_to_bounds,
148 operators.MESH_OT_print3d_align_to_xy,
149 operators.MESH_OT_print3d_export,
153 def register():
154 for cls in classes:
155 bpy.utils.register_class(cls)
157 bpy.types.Scene.print_3d = PointerProperty(type=SceneProperties)
160 def unregister():
161 for cls in classes:
162 bpy.utils.unregister_class(cls)
164 del bpy.types.Scene.print_3d