diff --git a/notebook_nueva/hinged_lid.py b/notebook_nueva/hinged_lid.py index f97286b..b7809b7 100644 --- a/notebook_nueva/hinged_lid.py +++ b/notebook_nueva/hinged_lid.py @@ -7,76 +7,99 @@ from modelo import ( ti_depth, ti_radius, width, + thickness as model_thickness, + shell_t, ) +import keyboard +import screen_mount + hinge_radius = 6 screw_radius = 1.5 # M3 ring_radius = 5 # M3 hinge_offset = max(p[1] for p in mounting_pillar_positions) + 6 -thickness = 5 hinge_width = 25 +thickness = 50 + +distance_to_kbd_top = hinge_radius + 15 # measure def model(): - # Create the basic shape of the case bottom. + # Create a 2-part hinged lid model = ( cq.Workplane("XY") # Hollow box - .box(width, height, 5) + .workplane(offset=-thickness / 2) + .box(width, height, thickness) + .faces("X") .workplane(centerOption="CenterOfBoundBox") - .center(height / 2 - hinge_offset, -hinge_radius + thickness / 2) + .center(height / 2 - hinge_offset, thickness / 2 - hinge_radius) .tag("rightSide") .placeSketch(cq.Sketch().circle(hinge_radius)) .extrude(-width) - # Cut middle section - .faces(">X") - .workplane(centerOption="CenterOfBoundBox", offset=-hinge_width) - .center(height / 2 - hinge_offset, 0) - .placeSketch(cq.Sketch().trapezoid(hinge_radius * 2 + 0.1, 20, 90)) - .cutBlind(-width + 2 * hinge_width) + # Cut middle section between the hinges + .workplaneFromTagged("rightSide") + .workplane(offset=-hinge_width) + .placeSketch( + cq.Sketch().polygon( + [ + (-hinge_radius, -hinge_radius), + (-hinge_radius, 0), + (-hinge_radius - shell_t, hinge_radius), + (-shell_t, hinge_radius), + (-shell_t, hinge_radius - shell_t), + (hinge_radius, hinge_radius - shell_t), + (hinge_radius, -hinge_radius), + (-hinge_radius, -hinge_radius), + ] + ) + ) + .cutBlind(-width + 2 * hinge_width - 1) # Hole for screws - .faces(">X") - .workplane(centerOption="CenterOfBoundBox") - .center(height / 2 - hinge_offset, 0) + .workplaneFromTagged("rightSide") .placeSketch(cq.Sketch().circle(screw_radius)) .cutBlind(-width) # Holes for rings & screw heads - .faces(">X") - .workplane(centerOption="CenterOfBoundBox") - .center(height / 2 - hinge_offset, 0) + .workplaneFromTagged("rightSide") .placeSketch(cq.Sketch().circle(ring_radius)) .cutBlind(-5) - .faces(">X") - .workplane(centerOption="CenterOfBoundBox", offset=-width + 4) - .center(height / 2 - hinge_offset, 0) + .workplaneFromTagged("rightSide") + .workplane(offset=-width + 4) .placeSketch(cq.Sketch().circle(ring_radius)) .cutBlind(-5) # Split hinge halves .faces(">X") - .workplane(centerOption="CenterOfBoundBox", offset=-hinge_width / 2) - .center(height / 2 - hinge_offset, 0) + .workplaneFromTagged("rightSide") + .workplane(offset=-hinge_width / 2) .placeSketch(cq.Sketch().trapezoid(hinge_radius * 2 + 1, hinge_radius * 2, 90)) - .cutBlind(2) - .faces(">X") - .workplane(centerOption="CenterOfBoundBox", offset=-width + hinge_width / 2) - .center(height / 2 - hinge_offset, 0) + .cutBlind(-1) + .workplaneFromTagged("rightSide") + .workplane(offset=-hinge_width) + .placeSketch(cq.Sketch().trapezoid(hinge_radius * 2 + 1, hinge_radius * 2, 90)) + .cutBlind(-1) + .workplaneFromTagged("rightSide") + .workplane(offset=-width + hinge_width / 2) + .placeSketch(cq.Sketch().trapezoid(hinge_radius * 2 + 1, hinge_radius * 2, 90)) + .cutBlind(-1) + .workplaneFromTagged("rightSide") + .workplane(offset=-width + hinge_width) .placeSketch(cq.Sketch().trapezoid(hinge_radius * 2 + 1, hinge_radius * 2, 90)) .cutBlind(-1) # Threaded inserts - .faces(">X") - .workplane(centerOption="CenterOfBoundBox", offset=-hinge_width / 2) - .center(height / 2 - hinge_offset, 0) + .workplaneFromTagged("rightSide") + .workplane(offset=-hinge_width / 2) .placeSketch(cq.Sketch().circle(ti_radius)) .cutBlind(-ti_depth) - .faces(">X") - .workplane(centerOption="CenterOfBoundBox", offset=-width + hinge_width / 2) - .center(height / 2 - hinge_offset, 0) + .workplaneFromTagged("rightSide") + .workplane(offset=-width + hinge_width / 2) .placeSketch(cq.Sketch().circle(ti_radius)) .cutBlind(ti_depth) # Split two halves + # First cut for the right hinge .workplaneFromTagged("rightSide") .placeSketch( cq.Sketch() @@ -84,14 +107,24 @@ def model(): [ (0, 0), (-hinge_radius - 0.2, 0), - (-hinge_radius - 0.2, hinge_radius), + (-hinge_radius - shell_t, hinge_radius), (0, hinge_radius), (0, 0), ] ) + .polygon( + [ + (-hinge_radius - 0.2, 0), + (-hinge_radius - 0.2, -1000), + (-hinge_radius, -1000), + (-hinge_radius, 0), + (-hinge_radius - 0.2, 0), + ] + ) .circle(hinge_radius, mode="s") ) - .cutBlind("next") + .cutBlind(-hinge_width / 2 - 1) + # Second cut for the right hinge .workplaneFromTagged("rightSide") .workplane(offset=-hinge_width / 2) .placeSketch( @@ -100,30 +133,32 @@ def model(): [ (0, 0), (hinge_radius + 0.2, 0), - (hinge_radius + 0.2, hinge_radius), + (hinge_radius + 0.2 + shell_t, hinge_radius), (0, hinge_radius), (0, 0), ] ) .circle(hinge_radius, mode="s") ) - .cutBlind(-hinge_width/2) + .cutBlind(-hinge_width / 2 - 1) + # First cut for the left hinge .workplaneFromTagged("rightSide") - .workplane(offset=-width+hinge_width) + .workplane(offset=-width + hinge_width) .placeSketch( cq.Sketch() .polygon( [ (0, 0), (hinge_radius + 0.2, 0), - (hinge_radius + 0.2, hinge_radius), + (hinge_radius + 0.2 + shell_t, hinge_radius), (0, hinge_radius), (0, 0), ] ) .circle(hinge_radius, mode="s") ) - .cutBlind(-hinge_width / 2) + .cutBlind(-hinge_width / 2 - 1) + # Second cut for the left hinge .workplaneFromTagged("rightSide") .workplane(offset=-width + hinge_width / 2) .placeSketch( @@ -132,14 +167,45 @@ def model(): [ (0, 0), (-hinge_radius - 0.2, 0), - (-hinge_radius - 0.2, hinge_radius), + (-hinge_radius - shell_t, hinge_radius), (0, hinge_radius), (0, 0), ] ) + .polygon( + [ + (-hinge_radius - 0.2, 0), + (-hinge_radius - 0.2, -1000), + (-hinge_radius, -1000), + (-hinge_radius, 0), + (-hinge_radius - 0.2, 0), + ] + ) .circle(hinge_radius, mode="s") ) - .cutBlind(-hinge_width / 2) + .cutBlind(-hinge_width / 2 - 1) + ) + + # Cut off shape of the base + + model = ( + model.workplaneFromTagged("rightSide") + .center(-height + hinge_offset, -thickness + hinge_radius) + .placeSketch( + cq.Sketch().polygon( + [ + (0, 0), + (0, keyboard.front_thickness), + (shell_t, keyboard.front_thickness), + (keyboard.actual_height + shell_t, keyboard.back_thickness), + (keyboard.actual_height + shell_t, model_thickness), + (height, model_thickness), + (height, 0), + (0, 0), + ] + ) + ) + .cutBlind(-1000) ) return model @@ -147,4 +213,14 @@ def model(): if __name__ == "__main__": model = model() + exporters.export(model, "hinged_lid.stl") + + exporters.export( + model, + "hinged_lid.svg", + opt={ + "projectionDir": (0, 0, 1), + "strokeWidth": 0.3, + }, + ) diff --git a/notebook_nueva/hinged_lid.stl b/notebook_nueva/hinged_lid.stl index 2b3b6ee..968e52d 100644 Binary files a/notebook_nueva/hinged_lid.stl and b/notebook_nueva/hinged_lid.stl differ diff --git a/notebook_nueva/hinged_lid.svg b/notebook_nueva/hinged_lid.svg new file mode 100644 index 0000000..5803251 --- /dev/null +++ b/notebook_nueva/hinged_lid.svg @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +