Beginnings of the notebook style lid
This commit is contained in:
parent
a1f3948756
commit
f2d2f652c4
150
notebook_nueva/hinged_lid.py
Normal file
150
notebook_nueva/hinged_lid.py
Normal 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")
|
BIN
notebook_nueva/hinged_lid.stl
Normal file
BIN
notebook_nueva/hinged_lid.stl
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user