lower case as model

This commit is contained in:
Ricardo (XenGi) Band 2022-02-22 03:42:49 +01:00
commit a68cc9ef53
No known key found for this signature in database
GPG key ID: 1A9D657D06B5820E
2 changed files with 33 additions and 25 deletions

View file

@ -1,6 +1,6 @@
from solid import OpenSCADObject, hull, translate, sphere, cube, scale, offset, square
from util import PCB_WIDTH, PCB_HEIGHT, PCB_RADIUS
from util import PCB_WIDTH, PCB_HEIGHT, PCB_RADIUS, forward, backward, up, right
def lower_case(phone_width: float, phone_height: float, phone_radius: float) -> OpenSCADObject:
@ -15,33 +15,35 @@ def lower_case(phone_width: float, phone_height: float, phone_radius: float) ->
thickness = 2
window_thickness = 0.5
return (scale(v=(1, 1, thickness / phone_radius))(
hull()(
translate(v=(phone_radius, phone_radius, 0))(
sphere(r=phone_radius),
translate(v=(0, phone_height - 2 * phone_radius, 0))(
sphere(r=phone_radius)
),
translate(v=(phone_width - 2 * phone_radius, 0, 0))(
sphere(r=phone_radius)
),
translate(v=(phone_width - 2 * phone_radius, phone_height - 2 * phone_radius, 0))(
sphere(r=phone_radius)
return forward(v=thickness)(
(scale(v=(1, 1, thickness / phone_radius))(
hull()(
translate(v=(phone_radius, phone_radius, 0))(
sphere(r=phone_radius),
up(v=phone_height - 2 * phone_radius)(
sphere(r=phone_radius)
),
right(v=phone_width - 2 * phone_radius)(
sphere(r=phone_radius)
),
translate(v=(phone_width - 2 * phone_radius, phone_height - 2 * phone_radius, 0))(
sphere(r=phone_radius)
)
)
)
)
) * translate(v=(0, 0, -1 * thickness))(
cube([phone_width, phone_height, thickness])
)) - translate(v=(2 * phone_radius, 2 * phone_radius, -1 * thickness / 2))(
scale(v=(1, 1, thickness))(
offset(r=phone_radius)(
square([phone_width - 4 * phone_radius, phone_height - 4 * phone_radius])
) * backward(v=thickness)(
cube([phone_width, phone_height, thickness])
)) - translate(v=(2 * phone_radius, 2 * phone_radius, -1 * thickness / 2))(
scale(v=(1, 1, thickness))(
offset(r=phone_radius)(
square([phone_width - 4 * phone_radius, phone_height - 4 * phone_radius])
)
)
)
) - translate(v=(phone_width - PCB_WIDTH, phone_radius, -1 * thickness / 2 + window_thickness))(
scale(v=(1, 1, thickness))(
offset(r=PCB_RADIUS)(
square([PCB_WIDTH - 2 * PCB_RADIUS, PCB_HEIGHT - 2 * PCB_RADIUS])
) - translate(v=(phone_width - PCB_WIDTH, phone_radius, -1 * thickness / 2 + window_thickness))(
scale(v=(1, 1, thickness))(
offset(r=PCB_RADIUS)(
square([PCB_WIDTH - 2 * PCB_RADIUS, PCB_HEIGHT - 2 * PCB_RADIUS])
)
)
)
)

View file

@ -10,6 +10,7 @@ from solid import scad_render_to_file
from key_mat import key_mat, key
from pcb import pcb
from phone import phone
from lower_case import lower_case
@click.command()
@ -61,6 +62,11 @@ def cli(layout, variant, stl, emf, amf, detail, config_file):
key_height=config.getfloat("key_mat", "key_height", fallback=6),
key_padding=config.getfloat("key_mat", "padding", fallback=1)
)],
["lower_case", lower_case(
phone_width=config.getfloat("phone", "width"),
phone_height=config.getfloat("phone", "height"),
phone_radius=config.getfloat("phone", "corner_radius")
)],
["test_key_mat", key_mat(
margin=config.getfloat("key_mat", "margin", fallback=1),
padding=config.getfloat("key_mat", "padding", fallback=1),