-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhallowing_m0_cover.py
129 lines (109 loc) · 3.8 KB
/
hallowing_m0_cover.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
"""
MIT License
Copyright (c) 2024 Roger Cheng
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
"""
Minimal cover over a HalloWing M0 screen. Not really for protection but to
hold it together. The screen is only held together by double-sided tape and
that tape has started failing due to age and the screen falling apart.
"""
import cadquery as cq
mm_per_inch = 25.4
fastener_distance_x = 0.7 * mm_per_inch
fastener_distance_y = 1.8 * mm_per_inch
fastener_border = 8
fastener_length = 5
nut_depth = 2.5
screen_outer_x = 30.5
screen_outer_y = 35 # Don't fit tightly to this dimension: FPC on top
screen_outer_z = 4.5
screen_visible_x = 26
screen_visible_y = 26
screen_visible_offset_x = 0
screen_visible_offset_y = -1
screen_center_offset_x = 0
screen_center_offset_y = -0.5
screen_border = 1.6
screen_opening_tolerance = 1
fastener_frame = (
cq.Workplane("XY")
.box(fastener_distance_x + fastener_border,
fastener_distance_y + fastener_border,
fastener_length
)
)
# Exterior of screen frame
screen_frame = (
cq.Workplane("XY")
.box(screen_outer_x + screen_opening_tolerance + screen_border,
screen_outer_y + screen_opening_tolerance + screen_border,
fastener_length
)
.translate((screen_center_offset_x, screen_center_offset_y, 0))
)
# Combine exterior of frames
fastener_frame = fastener_frame + screen_frame
# Smooth out corners
fastener_frame = fastener_frame.edges("|Z").fillet(1)
# Holes for M2.5 fasteners
fastener_frame = (
fastener_frame.faces("<Z")
.workplane()
.rect(fastener_distance_x, fastener_distance_y, forConstruction=True)
.vertices()
.circle(2.7/2)
.extrude(-(fastener_length - nut_depth - 0.2),combine='cut')
)
# Capture M2.5 nuts
fastener_frame = (
fastener_frame.faces(">Z")
.workplane()
.rect(fastener_distance_x, fastener_distance_y, forConstruction=True)
.vertices()
.polygon(6, 6.0)
.extrude(-nut_depth, combine='cut')
)
# Cut out space for screen
fastener_frame = (
fastener_frame.faces("<Z").workplane()
.transformed(offset=cq.Vector(
screen_center_offset_x,
-screen_center_offset_y, # Is Y coordinates reversed because of <Z face?
0))
.rect(
screen_outer_x + screen_opening_tolerance,
screen_outer_y + screen_opening_tolerance,
)
.extrude(-screen_outer_z, combine='cut')
)
# Cut screen opening
fastener_frame = (
fastener_frame.faces(">Z").workplane()
.transformed(offset=cq.Vector(
screen_visible_offset_x,
screen_visible_offset_y,
0))
.rect(
screen_visible_x + screen_opening_tolerance,
screen_visible_y + screen_opening_tolerance
)
.extrude(-fastener_length, combine='cut')
)
# Flip over for printing
fastener_frame = fastener_frame.rotate((0,0,0),(0,1,0),180)
show_object(fastener_frame)