27 lines
825 B
Python
27 lines
825 B
Python
|
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)
|
||
|
)
|