Compare commits

...

4 Commits

Author SHA1 Message Date
Martin Frost f6ccde7848 Modify TRRS holder
This opens it up on the inner side.
2024-09-06 14:08:49 +02:00
Martin Frost e9423dbcf0 Fix more constant names 2024-09-05 15:09:17 +02:00
Martin Frost 1cd946e2fd Add TRRS holder 2024-09-05 14:15:06 +02:00
Martin Frost 8293ebe799 Use proper CONSTANT_FORMAT 2024-09-05 14:14:34 +02:00
5 changed files with 151 additions and 103 deletions

View File

@ -1,47 +1,50 @@
import datetime
from math import radians, sin, cos
"""
Generate Dactyl case
"""
from math import radians, sin
from lib import *
from shapes import *
import lib
import mat
switch_thickness = 1.3
switch_top_thickness = 2.8
web_thickness = 3
switch_rim_thickness = 2
SWITCH_THICKNESS = 1.3
SWITCH_TOP_THICKNESS = 2.8
WEB_THICKNESS = 3
SWITCH_RIM_THICKNESS = 2
post_width = 0.5
post_rad = post_width / 2
POST_WIDTH = 0.5
POST_RAD = POST_WIDTH / 2
keyhole_size = 13.8
keyswitch_height = 15
keyswitch_width = 15
KEYHOLE_SIZE = 13.8
KEYSWITCH_HEIGHT = 15
KEYSWITCH_WIDTH = 15
plate_outer_width = keyhole_size + switch_rim_thickness * 2
PLATE_OUTER_WIDTH = KEYHOLE_SIZE + SWITCH_RIM_THICKNESS * 2
max_num_rows = 4
num_cols = 6
num_pinky_columns = 2
MAX_NUM_ROWS = 4
NUM_COLS = 6
NUM_PINKY_COLUMNS = 2
cols_with_max_rows = [2, 3]
sa_profile_key_height = 2
cap_top_height = switch_top_thickness + sa_profile_key_height
SA_PROFILE_KEY_HEIGHT = 2
CAP_TOP_HEIGHT = SWITCH_TOP_THICKNESS + SA_PROFILE_KEY_HEIGHT
# extra space between the base of keys
extra_height = 3
extra_width = 3
mount_height = keyswitch_height
mount_width = keyswitch_width
EXTRA_HEIGHT = 3
EXTRA_WIDTH = 3
MOUNT_HEIGHT = KEYSWITCH_HEIGHT
MOUNT_WIDTH = KEYSWITCH_WIDTH
# use 10 for faster prototyping, 15 for real
tenting_angle = 11.0
z_offset = 9.0
TENTING_ANGLE = 11.0
Z_OFFSET = 9.0
should_include_risers = False
SHOULD_INCLUDE_RISERS = False
def is_pinky(col):
return col >= num_cols - num_pinky_columns
return col >= NUM_COLS - NUM_PINKY_COLUMNS
# aka: alpha
@ -53,13 +56,13 @@ def row_curve_deg(col):
# aka: beta
col_curve_deg = 4.0
column_radius = cap_top_height + ((mount_width + extra_width) / 2) / sin(
column_radius = CAP_TOP_HEIGHT + ((MOUNT_WIDTH + EXTRA_WIDTH) / 2) / sin(
radians(col_curve_deg) / 2
)
def row_radius(col):
return cap_top_height + ((mount_height + extra_height) / 2) / sin(
return CAP_TOP_HEIGHT + ((MOUNT_HEIGHT + EXTRA_HEIGHT) / 2) / sin(
radians(row_curve_deg(col)) / 2
)
@ -80,13 +83,13 @@ def column_extra_transform(col):
def num_rows_for_col(col):
if col in cols_with_max_rows:
return max_num_rows
return MAX_NUM_ROWS
else:
return max_num_rows - 1
return MAX_NUM_ROWS - 1
def does_coord_exist(row, col):
return col >= 0 and col < num_cols and row >= 0 and row < num_rows_for_col(col)
return col >= 0 and col < NUM_COLS and row >= 0 and row < num_rows_for_col(col)
def negative(vect):
@ -102,21 +105,21 @@ def bottom_hull(shape):
def single_switch_fn():
outer_width = keyhole_size + switch_rim_thickness * 2
outer_width = KEYHOLE_SIZE + SWITCH_RIM_THICKNESS * 2
bottom_wall = cube(outer_width, switch_rim_thickness, switch_thickness)
top_wall = translate(0, keyhole_size + switch_rim_thickness, 0)(bottom_wall)
bottom_wall = cube(outer_width, SWITCH_RIM_THICKNESS, SWITCH_THICKNESS)
top_wall = translate(0, KEYHOLE_SIZE + SWITCH_RIM_THICKNESS, 0)(bottom_wall)
left_wall = cube(switch_rim_thickness, outer_width, switch_thickness)
right_wall = translate(keyhole_size + switch_rim_thickness, 0, 0)(left_wall)
left_wall = cube(SWITCH_RIM_THICKNESS, outer_width, SWITCH_THICKNESS)
right_wall = translate(KEYHOLE_SIZE + SWITCH_RIM_THICKNESS, 0, 0)(left_wall)
nub_len = 2.75
nub_cyl = translate(0, 0, -1)(rotate_x(90)(cylinder(1, nub_len, 30, center=True)))
# nub_cube = translate(-switch_rim_thickness / 2, 0, 0.)(cube(switch_rim_thickness, nub_len, 4, center=True))
# left_nub = translate(switch_rim_thickness, (outer_width) / 2, 0)(hull(nub_cyl, nub_cube))
# nub_cube = translate(-SWITCH_RIM_THICKNESS / 2, 0, 0.)(cube(SWITCH_RIM_THICKNESS, nub_len, 4, center=True))
# left_nub = translate(SWITCH_RIM_THICKNESS, (outer_width) / 2, 0)(hull(nub_cyl, nub_cube))
# right_nub_cube = translate(switch_rim_thickness / 2, 0, 0)(cube(switch_rim_thickness, nub_len, 4, center=True))
# right_nub = translate(-switch_rim_thickness + outer_width, (outer_width) / 2, 0)(hull(nub_cyl, right_nub_cube))
# right_nub_cube = translate(SWITCH_RIM_THICKNESS / 2, 0, 0)(cube(SWITCH_RIM_THICKNESS, nub_len, 4, center=True))
# right_nub = translate(-SWITCH_RIM_THICKNESS + outer_width, (outer_width) / 2, 0)(hull(nub_cyl, right_nub_cube))
return translate(-outer_width / 2, -outer_width / 2, 0)(
union(
@ -132,8 +135,8 @@ def single_switch_fn():
single_switch = single_switch_fn()
filled_switch = translate(0, 0, switch_thickness / 2.0)(
cube(plate_outer_width, plate_outer_width, switch_thickness, center=True)
filled_switch = translate(0, 0, SWITCH_THICKNESS / 2.0)(
cube(PLATE_OUTER_WIDTH, PLATE_OUTER_WIDTH, SWITCH_THICKNESS, center=True)
)
sa_length = 16.5
@ -160,7 +163,7 @@ def sa_cap_fn():
top = translate(0, 0, sa_extra_height)(top)
return colour(220, 163, 163, 1)(
translate(0, 0, switch_top_thickness + 1.5)(hull(bot, mid, top))
translate(0, 0, SWITCH_TOP_THICKNESS + 1.5)(hull(bot, mid, top))
)
@ -168,8 +171,8 @@ sa_cap = sa_cap_fn()
def row_cols():
for row in range(max_num_rows):
for col in range(num_cols):
for row in range(MAX_NUM_ROWS):
for col in range(NUM_COLS):
if row < num_rows_for_col(col):
yield (row, col)
@ -178,11 +181,11 @@ def all_of_shape(shape):
return [grid_position(row, col, shape) for (row, col) in row_cols()]
web_post = translate(-post_rad, -post_rad, switch_thickness - web_thickness)(
cube(post_width, post_width, web_thickness)
web_post = translate(-POST_RAD, -POST_RAD, SWITCH_THICKNESS - WEB_THICKNESS)(
cube(POST_WIDTH, POST_WIDTH, WEB_THICKNESS)
)
short_web_post = translate(-post_rad, -post_rad, 0)(
cube(post_width, post_width, post_width)
short_web_post = translate(-POST_RAD, -POST_RAD, 0)(
cube(POST_WIDTH, POST_WIDTH, POST_WIDTH)
)
SQUARE_OFFSET_IDXS = [
@ -209,7 +212,7 @@ def apply_translate_square(square, shape):
return square_apply(square, fn)
outer_post_delta = keyhole_size / 2 + switch_rim_thickness # - post_rad/2
outer_post_delta = KEYHOLE_SIZE / 2 + SWITCH_RIM_THICKNESS # - POST_RAD/2
outer_post_translate_square = square_translater_at_offset(outer_post_delta)
@ -221,7 +224,7 @@ web_post_bl = translate(-outer_post_delta, -outer_post_delta, 0)(web_post)
web_posts = apply_translate_square(outer_post_translate_square, web_post)
short_web_posts = apply_translate_square(outer_post_translate_square, short_web_post)
inner_post_delta = keyhole_size / 2 + post_rad
inner_post_delta = KEYHOLE_SIZE / 2 + POST_RAD
inner_post_translate_square = square_translater_at_offset(inner_post_delta)
inner_web_posts = apply_translate_square(inner_post_translate_square, web_post)
@ -304,8 +307,8 @@ def place_on_grid_base(row, column, domain):
# Column offset
domain.translate(*column_offset(column)),
# Misc
domain.rotate_y(tenting_angle),
domain.translate(0, 0, z_offset),
domain.rotate_y(TENTING_ANGLE),
domain.translate(0, 0, Z_OFFSET),
)
@ -331,8 +334,8 @@ def connectors():
return hull(*posts1, *posts2)
all_connectors = []
for col in range(num_cols - 1):
for row in range(max_num_rows):
for col in range(NUM_COLS - 1):
for row in range(MAX_NUM_ROWS):
if does_coord_exist(row, col) and does_coord_exist(row, col + 1):
if (row, col) == (0, 3):
right_edge = [
@ -348,8 +351,8 @@ def connectors():
)
)
for col in range(num_cols):
for row in range(max_num_rows - 1):
for col in range(NUM_COLS):
for row in range(MAX_NUM_ROWS - 1):
if does_coord_exist(row, col) and does_coord_exist(row + 1, col):
all_connectors.append(
make_edge_connection(
@ -357,7 +360,7 @@ def connectors():
)
)
for col in range(num_cols - 1):
for col in range(NUM_COLS - 1):
row = num_rows_for_col(col) - 1
next_col = col + 1
next_row = num_rows_for_col(next_col) - 1
@ -395,8 +398,8 @@ def connectors():
return False
return True
for col in range(num_cols - 1):
for row in range(max_num_rows - 1):
for col in range(NUM_COLS - 1):
for row in range(MAX_NUM_ROWS - 1):
if does_diag_exist(row, col):
p1 = grid_position(row, col, web_post_br)
p2 = grid_position(row + 1, col, web_post_tr)
@ -487,7 +490,7 @@ def wall_connect_from_placer(
shapes = []
if should_include_risers:
if SHOULD_INCLUDE_RISERS:
shapes.append(hull(place_fn1(post1), place_fn2(post2)))
if connectors:
@ -515,15 +518,15 @@ def case_walls():
all_shapes = []
# Top wall
for col in range(0, num_cols):
for col in range(0, NUM_COLS):
all_shapes.append(wall_connect(0, col, square_idx_tl, 0, col, square_idx_tr))
for col in range(0, num_cols - 1):
for col in range(0, NUM_COLS - 1):
all_shapes.append(
wall_connect(0, col, square_idx_tr, 0, col + 1, square_idx_tl)
)
# Right wall
max_col = num_cols - 1
max_col = NUM_COLS - 1
for row in range(0, num_rows_for_col(max_col)):
all_shapes.append(
wall_connect(row, max_col, square_idx_tr, row, max_col, square_idx_br)
@ -545,7 +548,7 @@ def case_walls():
def include_wall(col):
return col >= 2
for col in range(0, num_cols):
for col in range(0, NUM_COLS):
all_shapes.append(
wall_connect(
num_rows_for_col(col) - 1,
@ -557,7 +560,7 @@ def case_walls():
walls=include_wall(col),
)
)
for col in range(0, num_cols - 1):
for col in range(0, NUM_COLS - 1):
all_shapes.append(
wall_connect(
num_rows_for_col(col) - 1,
@ -984,7 +987,7 @@ def bottom_edge_at_position(row, col):
def bottom_edge_iterator():
for col in range(num_cols):
for col in range(NUM_COLS):
row = num_rows_for_col(col) - 1
yield from bottom_edge_at_position(row, col)
@ -1047,53 +1050,68 @@ def screw_insert(col, row, shape, ox, oy):
def screw_insert_all_shapes(shape):
return union(
screw_insert(2, 0, shape, -5.3, 5.9),
screw_insert(num_cols - 1, 0, shape, 6.7, 5.5),
screw_insert(num_cols - 1, num_rows_for_col(num_cols - 1), shape, 6.8, 14.4),
screw_insert(NUM_COLS - 1, 0, shape, 6.7, 5.5),
screw_insert(NUM_COLS - 1, num_rows_for_col(NUM_COLS - 1), shape, 6.8, 14.4),
screw_insert(0, 0, shape, -6.2, -8),
screw_insert(1, max_num_rows + 1, shape, -9.8, 3.4),
screw_insert(0, max_num_rows - 1, shape, -17.4, -2),
screw_insert(1, MAX_NUM_ROWS + 1, shape, -9.8, 3.4),
screw_insert(0, MAX_NUM_ROWS - 1, shape, -17.4, -2),
)
trrs_holder_size = [6.0, 11.0, 7.0]
trrs_hole_size = [2.6, 10.0]
trrs_holder_thickness = 2.5
trrs_front_thickness = 1.8
TRRS_HOLDER_SIZE = [6.0, 11.0, 7.0]
TRRS_HOLE_SIZE = [2.6, 10.0]
TRRS_HOLDER_THICKNESS = 2.5
TRRS_FRONT_THICKNESS = 1.8
def trrs_key_holder_position():
base_place = point_on_grid(0, 0, 0, keyswitch_width / 2, 0)
base_place = point_on_grid(0, 0, 0, KEYSWITCH_WIDTH / 2, 0)
return [base_place[0] - 5, base_place[1] + 1.43, 9.0]
def trrs_holder():
shape = cube(
trrs_holder_size[0] + trrs_holder_thickness,
trrs_holder_size[1] + trrs_front_thickness,
trrs_holder_size[2] + trrs_holder_thickness * 2,
TRRS_HOLDER_SIZE[0] + TRRS_HOLDER_THICKNESS,
TRRS_HOLDER_SIZE[1] + TRRS_FRONT_THICKNESS,
TRRS_HOLDER_SIZE[2] + TRRS_HOLDER_THICKNESS * 2,
)
placed_shape = translate(
-trrs_holder_size[0] / 2,
-trrs_holder_size[1],
-(trrs_holder_size[2] / 2 + trrs_holder_thickness),
-TRRS_HOLDER_SIZE[0] / 2,
-TRRS_HOLDER_SIZE[1],
-(TRRS_HOLDER_SIZE[2] / 2 + TRRS_HOLDER_THICKNESS),
)(shape)
return translate(*trrs_key_holder_position())(placed_shape)
def trrs_holder_hole():
rect_hole = cube(*trrs_holder_size)
x, y, z = TRRS_HOLDER_SIZE
rect_hole = cube(x, y, z)
rect_hole = translate(
-trrs_holder_size[0] / 2, -trrs_holder_size[1], -trrs_holder_size[2] / 2,
-x / 2, -y - 1, -z / 2,
)(rect_hole)
cylinder_hole = cylinder(*trrs_hole_size, segments=30)
rect2 = cube(x, y, z - 3)
rect2 = translate(
-x / 2 + 5, -y - 1, -z / 3,
)(rect2)
cylinder_hole = cylinder(*TRRS_HOLE_SIZE, segments=30)
cylinder_hole = rotate_x(90)(cylinder_hole)
cylinder_hole = translate(0, 5, 0)(cylinder_hole)
return translate(*trrs_key_holder_position())(union(rect_hole, cylinder_hole))
return translate(
*trrs_key_holder_position()
)(
union(
union(
rect_hole,
rect2,
),
cylinder_hole
)
)
usb_holder_hole_dims = [9, 8, 3.5]
@ -1101,7 +1119,7 @@ usb_holder_thickness = 0.5
def usb_holder_position():
base_place = point_on_grid(0, 0, 0, keyswitch_width / 2, 0)
base_place = point_on_grid(0, 0, 0, KEYSWITCH_WIDTH / 2, 0)
return [base_place[0] + 8, base_place[1] + 2, 4]
@ -1181,8 +1199,8 @@ reset_switch_body_hole = place_reset_switch_shape(unplaced_reset_switch_body_hol
def right_shell():
global should_include_risers
should_include_risers = True
global SHOULD_INCLUDE_RISERS
SHOULD_INCLUDE_RISERS = True
cover = translate(-60, 20, 0)(cube(15, 15, 20))
@ -1232,8 +1250,8 @@ def wall_shape():
def model_outline():
global should_include_risers
should_include_risers = True
global SHOULD_INCLUDE_RISERS
SHOULD_INCLUDE_RISERS = True
solid_bottom = project()(
union(
@ -1274,7 +1292,7 @@ def place_weight_hole(x, y):
def bottom_weight_cutouts():
shapes = []
base_point = point_on_grid(0, num_cols - 1, 0, 0, 0)
base_point = point_on_grid(0, NUM_COLS - 1, 0, 0, 0)
base_x = base_point[0] - 9
base_y = base_point[1] - 4
@ -1335,7 +1353,7 @@ def bottom_plate():
cylinderr1r2(screw_hole_radius, screw_hole_radius, bottom_height)
),
# bottom_weight_cutouts(),
# reset_switch_body_hole,
reset_switch_body_hole,
),
)
@ -1345,8 +1363,8 @@ def left_bottom_plate():
def thumb_corner():
global should_include_risers
should_include_risers = False
global SHOULD_INCLUDE_RISERS
SHOULD_INCLUDE_RISERS = False
return difference(
union(
thumb_switches(),

View File

@ -1,4 +1,4 @@
// Generated by SolidPython 0.4.8 on 2024-09-05 11:44:27
// Generated by SolidPython 0.4.8 on 2024-09-06 14:03:09
mirror(v = [-1, 0, 0]) {
@ -16302,9 +16302,14 @@ mirror(v = [-1, 0, 0]) {
}
translate(v = [-55.537912117550164, 27.807955392906404, 9.0000000000]) {
union() {
translate(v = [-3.0000000000, -11.0000000000, -3.5000000000]) {
union() {
translate(v = [-3.0000000000, -12.0000000000, -3.5000000000]) {
cube(size = [6.0000000000, 11.0000000000, 7.0000000000]);
}
translate(v = [2.0000000000, -12.0000000000, -2.3333333333]) {
cube(size = [6.0000000000, 11.0000000000, 4.0000000000]);
}
}
translate(v = [0, 5, 0]) {
rotate(a = 90, v = [1, 0, 0]) {
cylinder($fn = 30, h = 10.0000000000, r = 2.6000000000);

View File

@ -1,4 +1,4 @@
// Generated by SolidPython 0.4.8 on 2024-09-05 11:44:27
// Generated by SolidPython 0.4.8 on 2024-09-06 14:03:10
mirror(v = [-1, 0, 0]) {
@ -25859,6 +25859,16 @@ mirror(v = [-1, 0, 0]) {
cylinder($fn = 18, h = 2, r1 = 1.7000000000, r2 = 1.7000000000);
}
}
translate(v = [-35.39899073705581, 0.0, 0]) {
union() {
translate(v = [0, -2.5000000000, 4.1000000000]) {
cube(center = true, size = [6.2000000000, 6.5000000000, 4.2000000000]);
}
translate(v = [0, -2.5000000000, 1.0000000000]) {
cylinder($fn = 18, center = true, h = 2, r = 2.1500000000);
}
}
}
}
}
}

View File

@ -1,4 +1,4 @@
// Generated by SolidPython 0.4.8 on 2024-09-05 11:44:27
// Generated by SolidPython 0.4.8 on 2024-09-06 14:03:09
difference() {
@ -16301,9 +16301,14 @@ difference() {
}
translate(v = [-55.537912117550164, 27.807955392906404, 9.0000000000]) {
union() {
translate(v = [-3.0000000000, -11.0000000000, -3.5000000000]) {
union() {
translate(v = [-3.0000000000, -12.0000000000, -3.5000000000]) {
cube(size = [6.0000000000, 11.0000000000, 7.0000000000]);
}
translate(v = [2.0000000000, -12.0000000000, -2.3333333333]) {
cube(size = [6.0000000000, 11.0000000000, 4.0000000000]);
}
}
translate(v = [0, 5, 0]) {
rotate(a = 90, v = [1, 0, 0]) {
cylinder($fn = 30, h = 10.0000000000, r = 2.6000000000);

View File

@ -1,4 +1,4 @@
// Generated by SolidPython 0.4.8 on 2024-09-05 11:44:27
// Generated by SolidPython 0.4.8 on 2024-09-06 14:03:09
difference() {
@ -25858,6 +25858,16 @@ difference() {
cylinder($fn = 18, h = 2, r1 = 1.7000000000, r2 = 1.7000000000);
}
}
translate(v = [-35.39899073705581, 0.0, 0]) {
union() {
translate(v = [0, -2.5000000000, 4.1000000000]) {
cube(center = true, size = [6.2000000000, 6.5000000000, 4.2000000000]);
}
translate(v = [0, -2.5000000000, 1.0000000000]) {
cylinder($fn = 18, center = true, h = 2, r = 2.1500000000);
}
}
}
}
}
/***********************************************