rendering works

This commit is contained in:
Ricardo Band 2022-02-03 21:31:41 +01:00
commit 8ac92eca2c
4 changed files with 26 additions and 24 deletions

4
.gitignore vendored
View file

@ -1,8 +1,8 @@
.idea/
*gcode
*.gcode
*.stl
*.amf
*.3mf
*.scad
__pycache__/
*.pyc

View file

@ -1,14 +1,14 @@
[oneplus_8t]
phone_width=160.7
phone_height=74.1
phone_thickness=8.4
phone_corner_radius=10
phone_side_radius=5
key_mat_margin=1
key_mat_padding=1
key_mat_thickness=0.5
key_mat_key_width=9
key_mat_key_height=6
key_mat_key_corner_radius=1
key_mat_key_thickness=2
key_mat_font=DejaVu Sans:style=Bold
phone_width = 160.7
phone_height = 74.1
phone_thickness = 8.4
phone_corner_radius = 10
phone_side_radius = 5
key_mat_margin = 1
key_mat_padding = 1
key_mat_thickness = 0.5
key_mat_key_width = 9
key_mat_key_height = 6
key_mat_key_corner_radius = 1
key_mat_key_thickness = 2
key_mat_font = DejaVu Sans:style=Bold

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python3
"""
All sizes are in millimeters.
"""
import sys
from subprocess import run
from configparser import ConfigParser
@ -8,12 +10,13 @@ from configparser import ConfigParser
from solid import scad_render_to_file
from key_mat import key_mat
from phone import phone
def main(device: str = "oneplus_8t", layout: str = "ansi"):
config = ConfigParser()
config.read_file("config.ini")
config.read("config.ini")
if not config.has_section(device):
sys.exit(f"{device} not found in config.ini")
@ -45,22 +48,21 @@ def main(device: str = "oneplus_8t", layout: str = "ansi"):
component[1],
filepath=f"mkbd65_{component[0]}.scad",
file_header=f'$fn = 64;',
include_orig_code=True
include_orig_code=False
)
print(f"Generate STL for component {component[0]}...")
run(["openscad", "-o", f"mkbd65_{component[0]}.stl", f"mkbd65_{component[0]}.scad"])
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 __name__ == "__main__":
if "-h" in sys.argv or "--help" in sys.argv:
if "-h" in sys.argv or "--help" in sys.argv or len(sys.argv) < 2:
print("Usage:")
print(" ./main.py <PHONE> [LAYOUT]\n")
print("Layout can be ANSI or ISO.")
main(device=sys.argv[1])
else:
main(device=sys.argv[1])

View file

@ -6,15 +6,15 @@ FILAMENT_LAYER = 0.1
LAYOUTS = {
"ansi": [
["Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "Bksp", None],
["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "\\"],
["A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "\"", "Enter", None],
["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "\\\\"],
["A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "\\\"", "Enter", None],
["Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "Up", "Shift", None],
["Ctrl", "Fn", "Shift", "Alt", "Space", None, None, "-", "=", "Left", "Down", "Right", "Ctrl"]
],
"iso": [
["Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "Bksp", None],
["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "Ent"],
["A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "\"", "\\", None],
["A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "\\\"", "\\\\", None],
["Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "Up", "Shift", None],
["Ctrl", "Fn", "Shift", "Alt", "Space", None, None, "-", "=", "Left", "Down", "Right", "Ctrl"]
]