import cadquery as cq
w, h = 30.0,40.0
th, dia = 10.0, 22.0
pad, rf = 12.0, 5
cb_dia1,cb_dia2, cb_d = 2.5, 5, 4
ch = .5
result = (cq.Workplane().box(h, w, th)
.faces(">Z").workplane().hole(dia)
.faces(">Z").workplane()
.rect(h - pad, w - pad, forConstruction=True)
.vertices().cboreHole(cb_dia1,cb_dia2, cb_d)
.edges("|Z").fillet(rf).faces('>Z').chamfer(ch))from cadquery.func import *
r = rect(h, w)
locs_cbore = [v.Center() for v in rect(h-pad, w-pad).vertices()]
c = face(circle(dia/2))
cbs1 = face(circle(cb_dia1/2)).moved(locs_cbore)
cbs2 = face(circle(cb_dia2/2)).moved(locs_cbore).moved(z=th)
base = extrude(face(r), (0,0,th))
base = fillet(base, base.edges('|Z'), rf)
base -= compound(extrude(c, (0,0,th)), extrude(cbs1,(0,0,th)))
base -= extrude(cbs2, (0,0,-cb_d))
result = chamfer(base, base.faces('>Z').edges(), ch)cq.Shape objects+ is fuse()- is cut()* is intersect()/ is split()Shape.moved(...)Higher order topological entities can be assembled form lower order topological entities
Wire can be assembled from Edge objectsFace from Wire objectsSolid form Face objectsThis allows to build more complicated objects and often optimize boolean operations away
c1 = circle(1)
c2 = circle(2)
f_bot = loft(c1, c2)
sides = extrude(compound(c1,c2), (0,0,3))
f_top = loft(c1.moved(z=3), circle(1.5).moved(z=2.8), c2.moved(z=3))
result = solid(f_bot, sides, f_top)Shape objects can be checked for correctness
check(s: Shape) -> bool or err ==[]; check(s: Shape, err) -> boolWe can mix and match different APIs
cq.Workplane.add(...)cq.Sketch.face(...)cq.Workplane.val() -> cq.Shape, cq.Sketch.val() -> cq.Shapecq.Assembly.add(...)Shapeinvoke, filter, apply and map added to Workplane and Sketch__iter__ for Workplane and SketchWorkplane can operate on selected facesfrom cadquery.vis import show
f = face(rect(1,1))
show(f)
show(f, f.outerWire().sample(100), Location(z=10, rz=45))Location and Vector visualizationvtkActor supportCaduQuery helps design cutting edge nuclear fusion reactors.
10.5281/zenodo.3955118