2023-03-01 18:47:06 +00:00
|
|
|
import cadquery as cq
|
|
|
|
|
|
|
|
# TODO make API of extrude_shape and punch_hole more consistent
|
|
|
|
def extrude_shape(*, model, face, w, h, x_offset, y_offset, shape, height):
|
|
|
|
return (
|
|
|
|
model.faces(face)
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.center(-w / 2 + x_offset, -h / 2 + y_offset)
|
|
|
|
.placeSketch(shape)
|
|
|
|
.extrude(height)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def punch_hole(*, model, face, w, h, x_offset, y_offset, hole, depth):
|
|
|
|
return (
|
|
|
|
model.faces(face)
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.center(-w / 2 + x_offset + hole["x"], -h / 2 + y_offset + hole["y"])
|
|
|
|
.placeSketch(
|
|
|
|
cq.Sketch()
|
|
|
|
.trapezoid(hole["width"], hole["height"], 90, mode="a")
|
|
|
|
.vertices()
|
|
|
|
.fillet(hole["fillet"])
|
|
|
|
)
|
|
|
|
.cutBlind(-depth)
|
|
|
|
)
|
2023-03-08 20:24:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
def punch_hole2(*, model, face, w, h, x_offset, y_offset, hole, depth):
|
|
|
|
return (
|
|
|
|
model.faces(face)
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.center(-w / 2 + x_offset + hole["x"], -h / 2 + y_offset + hole["y"])
|
|
|
|
.placeSketch(hole["shape"])
|
|
|
|
.cutBlind(-depth)
|
2023-03-15 13:46:36 +00:00
|
|
|
)
|