Compare commits

..

2 Commits

Author SHA1 Message Date
f2d2f652c4 Beginnings of the notebook style lid 2023-04-04 18:04:53 -03:00
a1f3948756 Fix comments 2023-04-04 16:18:32 -03:00
3 changed files with 152 additions and 1 deletions

View File

@ -0,0 +1,150 @@
import cadquery as cq
from cadquery import exporters
from modelo import (
height,
mounting_pillar_positions,
ti_depth,
ti_radius,
width,
)
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
def model():
# Create the basic shape of the case bottom.
model = (
cq.Workplane("XY")
# Hollow box
.box(width, height, 5)
# Outer surface of the hinge
.faces(">X")
.workplane(centerOption="CenterOfBoundBox")
.center(height / 2 - hinge_offset, -hinge_radius + thickness / 2)
.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)
# Hole for screws
.faces(">X")
.workplane(centerOption="CenterOfBoundBox")
.center(height / 2 - hinge_offset, 0)
.placeSketch(cq.Sketch().circle(screw_radius))
.cutBlind(-width)
# Holes for rings & screw heads
.faces(">X")
.workplane(centerOption="CenterOfBoundBox")
.center(height / 2 - hinge_offset, 0)
.placeSketch(cq.Sketch().circle(ring_radius))
.cutBlind(-5)
.faces(">X")
.workplane(centerOption="CenterOfBoundBox", offset=-width + 4)
.center(height / 2 - hinge_offset, 0)
.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)
.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)
.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)
.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)
.placeSketch(cq.Sketch().circle(ti_radius))
.cutBlind(ti_depth)
# Split two halves
.workplaneFromTagged("rightSide")
.placeSketch(
cq.Sketch()
.polygon(
[
(0, 0),
(-hinge_radius - 0.2, 0),
(-hinge_radius - 0.2, hinge_radius),
(0, hinge_radius),
(0, 0),
]
)
.circle(hinge_radius, mode="s")
)
.cutBlind("next")
.workplaneFromTagged("rightSide")
.workplane(offset=-hinge_width / 2)
.placeSketch(
cq.Sketch()
.polygon(
[
(0, 0),
(hinge_radius + 0.2, 0),
(hinge_radius + 0.2, hinge_radius),
(0, hinge_radius),
(0, 0),
]
)
.circle(hinge_radius, mode="s")
)
.cutBlind(-hinge_width/2)
.workplaneFromTagged("rightSide")
.workplane(offset=-width+hinge_width)
.placeSketch(
cq.Sketch()
.polygon(
[
(0, 0),
(hinge_radius + 0.2, 0),
(hinge_radius + 0.2, hinge_radius),
(0, hinge_radius),
(0, 0),
]
)
.circle(hinge_radius, mode="s")
)
.cutBlind(-hinge_width / 2)
.workplaneFromTagged("rightSide")
.workplane(offset=-width + hinge_width / 2)
.placeSketch(
cq.Sketch()
.polygon(
[
(0, 0),
(-hinge_radius - 0.2, 0),
(-hinge_radius - 0.2, hinge_radius),
(0, hinge_radius),
(0, 0),
]
)
.circle(hinge_radius, mode="s")
)
.cutBlind(-hinge_width / 2)
)
return model
if __name__ == "__main__":
model = model()
exporters.export(model, "hinged_lid.stl")

Binary file not shown.

View File

@ -17,7 +17,7 @@ front_lip = 8
def model(): def model():
# Create the basic shape of the case bottom. # Create the basic shape of the case lid
model = ( model = (
cq.Workplane("XY") cq.Workplane("XY")
# Hollow box # Hollow box
@ -67,6 +67,7 @@ def model():
def decorative_cover(): def decorative_cover():
# A decorative thingie to cover the ugly seam in the middle
model = cq.Workplane("XY").box(10, height, 1).edges("|Z").fillet(1) model = cq.Workplane("XY").box(10, height, 1).edges("|Z").fillet(1)
vent = hex_vents(size=6, width=width * 0.9, height=height * 0.9, density=0.775)[0] vent = hex_vents(size=6, width=width * 0.9, height=height * 0.9, density=0.775)[0]