Moved specific keyboard sizes and positions to dimensions.py

This commit is contained in:
2023-04-15 19:21:03 -03:00
parent 158d7bfd87
commit 7217c7bc3b
7 changed files with 73 additions and 58 deletions

View File

@ -1,47 +1,40 @@
import cadquery as cq
import math
# TODO: move dimensions to dimensions.py
# Size of the kbd board
kbd_height = 95.5
kbd_width = 305
back_thickness = 19
front_thickness = 12
# These should be set from dimensions.py
elements = None
kbd_pillar_positions = []
kbd_height = 0
kbd_width = 0
kbd_back_thickness = 0
kbd_front_thickness = 0
kbd_actual_height = 0
kbd_angle = 0
# Pythagoras
actual_height = (kbd_height**2 - (back_thickness - front_thickness) ** 2) ** 0.5
kbd_angle = math.acos(actual_height / kbd_height) * 180 / math.pi
kbd_pillar_positions = [
(19, 16),
(142.5, 25.5),
(kbd_width - 20, 16),
(23.5, 79.5),
(145.5, 82.5),
(kbd_width - 19, 79.5),
]
def init():
global elements
elements = [
# Shorter pillars
{
"x": 0,
"y": 0,
"z": 5.5,
"shape": cq.Sketch().push(kbd_pillar_positions).circle(5, mode="a"),
},
# Taller pillars with holes for self-tapping screws
{
"x": 0,
"y": 0,
"z": 2.5,
"shape": (
cq.Sketch()
.push(kbd_pillar_positions)
.circle(2.4, mode="a")
.circle(1.1, mode="s")
),
},
]
elements = [
# Shorter pillars
{
"x": 0,
"y": 0,
"z": 5.5,
"shape": cq.Sketch().push(kbd_pillar_positions).circle(5, mode="a"),
},
# Taller pillars with holes for self-tapping screws
{
"x": 0,
"y": 0,
"z": 2.5,
"shape": (
cq.Sketch()
.push(kbd_pillar_positions)
.circle(2.4, mode="a")
.circle(1.1, mode="s")
),
},
]
def add(
@ -62,7 +55,7 @@ def add(
if bottom_face:
model = (
model.faces(bottom_face)
.workplane(centerOption="CenterOfBoundBox", offset=-front_thickness)
.workplane(centerOption="CenterOfBoundBox", offset=-kbd_front_thickness)
.center(
-width / 2,
height / 2,
@ -89,16 +82,15 @@ def add(
.placeSketch(
cq.Sketch().polygon(
[
[0, front_thickness],
[shell_t, front_thickness],
[actual_height + shell_t, back_thickness],
[actual_height + shell_t, 1000],
[0, kbd_front_thickness],
[shell_t, kbd_front_thickness],
[kbd_actual_height + shell_t, kbd_back_thickness],
[kbd_actual_height + shell_t, 1000],
[0, 1000],
[0, front_thickness],
[0, kbd_front_thickness],
]
)
)
.cutBlind(-1000)
)
return model