1 # SPDX-FileCopyrightText: 2013-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # Interface for this addon.
8 from bpy
.types
import Panel
14 class View3DPrintPanel
:
15 bl_category
= "3D-Print"
16 bl_space_type
= 'VIEW_3D'
20 def poll(cls
, context
):
21 obj
= context
.active_object
22 return obj
is not None and obj
.type == 'MESH' and obj
.mode
in {'OBJECT', 'EDIT'}
25 class VIEW3D_PT_print3d_analyze(View3DPrintPanel
, Panel
):
29 bmesh
.types
.BMVert
: 'VERTEXSEL',
30 bmesh
.types
.BMEdge
: 'EDGESEL',
31 bmesh
.types
.BMFace
: 'FACESEL',
34 def draw_report(self
, context
):
39 is_edit
= context
.edit_object
is not None
41 layout
.label(text
="Result")
45 for i
, (text
, data
) in enumerate(info
):
46 if is_edit
and data
and data
[1]:
47 bm_type
, _bm_array
= data
48 col
.operator("mesh.print3d_select_report", text
=text
, icon
=self
._type
_to
_icon
[bm_type
],).index
= i
52 def draw(self
, context
):
55 print_3d
= context
.scene
.print_3d
59 layout
.label(text
="Statistics")
60 row
= layout
.row(align
=True)
61 row
.operator("mesh.print3d_info_volume", text
="Volume")
62 row
.operator("mesh.print3d_info_area", text
="Area")
64 layout
.label(text
="Checks")
65 col
= layout
.column(align
=True)
66 col
.operator("mesh.print3d_check_solid", text
="Solid")
67 col
.operator("mesh.print3d_check_intersect", text
="Intersections")
68 row
= col
.row(align
=True)
69 row
.operator("mesh.print3d_check_degenerate", text
="Degenerate")
70 row
.prop(print_3d
, "threshold_zero", text
="")
71 row
= col
.row(align
=True)
72 row
.operator("mesh.print3d_check_distort", text
="Distorted")
73 row
.prop(print_3d
, "angle_distort", text
="")
74 row
= col
.row(align
=True)
75 row
.operator("mesh.print3d_check_thick", text
="Thickness")
76 row
.prop(print_3d
, "thickness_min", text
="")
77 row
= col
.row(align
=True)
78 row
.operator("mesh.print3d_check_sharp", text
="Edge Sharp")
79 row
.prop(print_3d
, "angle_sharp", text
="")
80 row
= col
.row(align
=True)
81 row
.operator("mesh.print3d_check_overhang", text
="Overhang")
82 row
.prop(print_3d
, "angle_overhang", text
="")
83 layout
.operator("mesh.print3d_check_all", text
="Check All")
85 self
.draw_report(context
)
88 class VIEW3D_PT_print3d_cleanup(View3DPrintPanel
, Panel
):
90 bl_options
= {"DEFAULT_CLOSED"}
92 def draw(self
, context
):
95 print_3d
= context
.scene
.print_3d
97 row
= layout
.row(align
=True)
98 row
.operator("mesh.print3d_clean_distorted", text
="Distorted")
99 row
.prop(print_3d
, "angle_distort", text
="")
100 layout
.operator("mesh.print3d_clean_non_manifold", text
="Make Manifold")
102 # layout.operator("mesh.print3d_clean_thin", text="Wall Thickness")
105 class VIEW3D_PT_print3d_edit(View3DPrintPanel
, Panel
):
107 bl_options
= {"DEFAULT_CLOSED"}
109 def draw(self
, context
):
112 print_3d
= context
.scene
.print_3d
114 layout
.operator("mesh.print3d_hollow")
115 layout
.label(text
="Scale To")
116 row
= layout
.row(align
=True)
117 row
.operator("mesh.print3d_scale_to_volume", text
="Volume")
118 row
.operator("mesh.print3d_scale_to_bounds", text
="Bounds")
119 row
= layout
.row(align
=True)
120 row
.operator("mesh.print3d_align_to_xy", text
="Align XY")
121 row
.prop(print_3d
, "use_alignxy_face_area")
124 class VIEW3D_PT_print3d_export(View3DPrintPanel
, Panel
):
126 bl_options
= {"DEFAULT_CLOSED"}
128 def draw(self
, context
):
130 layout
.use_property_split
= True
131 layout
.use_property_decorate
= False
133 print_3d
= context
.scene
.print_3d
135 layout
.prop(print_3d
, "export_path", text
="")
136 layout
.prop(print_3d
, "export_format")
138 col
= layout
.column()
139 col
.prop(print_3d
, "use_apply_scale")
140 col
.prop(print_3d
, "use_export_texture")
142 sub
.active
= print_3d
.export_format
!= "STL"
143 sub
.prop(print_3d
, "use_data_layers")
145 layout
.operator("mesh.print3d_export", text
="Export", icon
='EXPORT')