holy moly

This commit is contained in:
Ricardo (XenGi) Band 2022-02-06 15:18:46 +01:00
commit 5492defb20
No known key found for this signature in database
GPG key ID: 1A9D657D06B5820E
4 changed files with 22 additions and 9 deletions

1
.gitignore vendored
View file

@ -3,6 +3,7 @@
*.gcode
*.stl
*.3mf
*.amf
*.scad
__pycache__/
*.pyc

View file

@ -175,4 +175,12 @@ def key_mat(
label=LAYOUTS[f"{layout}_{variant}"][y][x]
))
for x in range(keys_h):
for y in range(keys_v):
mat -= translate(v=(padding_h + x * (key_width + padding_h) + 1, padding_v + (keys_v - y - 1) * (key_height + padding_v) + 1, 0))(
cube((key_width - 2, key_height - 2, key_thickness + thickness - 2 * FILAMENT_LAYER)) - translate(v=(key_width / 2 - 1, key_height / 2 - 1, 0))(
cylinder(d=2, h=key_thickness + thickness - 2 * FILAMENT_LAYER)
)
)
return color("DarkSlateGray")(mat)

View file

@ -2,7 +2,7 @@
"""
All sizes are in millimeters.
"""
import sys
from subprocess import run
from configparser import ConfigParser
@ -18,8 +18,14 @@ from phone import phone
@click.option("-v", "--variant", "variant", default="en", show_default=True, help="Keyboard layout variant", type=click.Choice(["en", "de"], case_sensitive=False))
@click.option("-s", "--stl", "stl", is_flag=True, help="Generate STL files")
@click.option("-3", "--3mf", "emf", is_flag=True, help="Generate 3MF files")
@click.option("-a", "--amf", "amf", is_flag=True, help="Generate AMF files")
@click.option("-d", "--detail", "detail", default=64, show_default=True, help="OpenSCAD detail level", type=click.INT)
@click.argument("config_file")
def cli(layout, variant, stl, emf, config_file):
def cli(layout, variant, stl, emf, amf, detail, config_file):
if layout == "ansi" and variant == "de":
click.echo("There is no german ansi variant. German keyboards need one more key and therefore use the ISO layout.")
sys.exit()
config = ConfigParser()
config.read(config_file)
@ -36,7 +42,7 @@ def cli(layout, variant, stl, emf, config_file):
height=config.getfloat("key_mat", "key_height", fallback=6),
thickness=config.getfloat("key_mat", "key_thickness", fallback=2),
corner_radius=config.getfloat("key_mat", "key_corner_radius", fallback=1),
label="G",
label="❤️",
font=config.get("key_mat", "font", fallback="DejaVu Sans:style=Bold")
)],
["key_mat", key_mat(
@ -58,7 +64,7 @@ def cli(layout, variant, stl, emf, config_file):
scad_render_to_file(
component[1],
filepath=f"mkbd65_{component[0]}.scad",
file_header=f'$fn = 64;',
file_header=f'$fn = {detail};',
include_orig_code=False
)
if stl:
@ -67,9 +73,9 @@ def cli(layout, variant, stl, emf, config_file):
if emf:
print(f"Generate 3MF for component {component[0]}...")
run(["openscad", "-o", f"mkbd65_{component[0]}.3mf", f"mkbd65_{component[0]}.scad"])
# obj_all = obj_phone + obj_key_mat
# scad_render_to_file(obj_all, filepath="mkbd65.scad", file_header=f'$fn = 64;', include_orig_code=True)
if amf:
print(f"Generate AMF for component {component[0]}...")
run(["openscad", "-o", f"mkbd65_{component[0]}.amf", f"mkbd65_{component[0]}.scad"])
if __name__ == "__main__":

View file

@ -16,5 +16,3 @@ key_height = 6
key_corner_radius = 1
key_thickness = 2
font = DejaVu Sans:style=Bold
#font = Liberation Mono:style=Bold
#font = Noto Sans:style=Bold