Beginnings of the notebook style lid

This commit is contained in:
Roberto Alsina 2023-04-04 18:04:53 -03:00
parent a1f3948756
commit f2d2f652c4
2 changed files with 150 additions and 0 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.