cadquery/notebook_nueva/components/screen_pillars.py

76 lines
1.8 KiB
Python
Raw Normal View History

from utils import extrude_shape, punch_hole
2023-03-21 13:56:17 +00:00
import cadquery as cq
elements = None
bottom_holes = None # Not really vents FIXME
def init(positions, thickness):
"""Because these need to match in multiple models, we create the
elemments dynamically"""
global elements, bottom_holes
elements = [
{
"x": 0,
"y": 0,
"shape": cq.Sketch().push(positions).trapezoid(12, 12, 90, mode="a"),
2023-03-21 13:56:17 +00:00
"height": thickness,
}
]
bottom_holes = [
{
"x": 0,
"y": 0,
"shape": cq.Sketch().push(positions).circle(3, mode="a"),
"depth": thickness - 13, # (screw thread length - threaded insert depth)
},
{
"x": 0,
"y": 0,
"shape": cq.Sketch().push(positions).circle(1.8, mode="a"),
"depth": 100,
},
2023-03-21 13:56:17 +00:00
]
def add(
*,
model,
width,
height,
thickness,
offset_x,
offset_y,
bottom_face,
back_face,
shell_t
):
if bottom_face:
# Mounting pillars
for element in elements:
model = extrude_shape(
model=model,
face=bottom_face,
w=width,
h=height,
x_offset=offset_x,
y_offset=shell_t + offset_y,
element=element,
2023-03-21 13:56:17 +00:00
height=-(element["height"] + shell_t),
)
# Screw holes
for hole in bottom_holes:
model = punch_hole(
2023-03-21 13:56:17 +00:00
model=model,
face=bottom_face,
w=width,
h=height,
x_offset=offset_x,
y_offset=shell_t + offset_y,
2023-03-21 13:56:17 +00:00
hole=hole,
depth=hole["depth"],
)
return model