36 lines
1.1 KiB
Python
36 lines
1.1 KiB
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)
|
|
)
|
|
|
|
|
|
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)
|
|
) |