cq_warehouse: The Hardware Store Hidden Inside CadQuery

A Python library that turns standards tables, fasteners, bearings, and threads into parametric solids, then reaches beneath CadQuery to patch in the missing industrial stuff.

9 min read • View on GitHub • More from gumyr

A tidy mechanical workbench with drawers labeled for nuts, bearings, threads, and sprockets opening into precise technical drawings. A laptop beside the drawers emits clean CAD solids, showing how standard hardware can be instantiated from code instead of redrawn by hand.
cq_warehouse behaves like a code-native hardware store, where standard parts are fetched by name and turned into geometry on demand.

cq_warehouse augments CadQuery with parametric parts - generated on demand - and extensions to the core CadQuery capabilities.

gumyr, Project Creator/Maintainer · cq_warehouse README
Key Takeaways

cq_warehouse looks like a parts library. It is more interesting than that. The repo turns standards tables into reusable geometry, then reaches under CadQuery's high-level API to add the missing industrial conveniences: BOM counts, text embossing, curved-surface projection, and part families that behave like code, not clip art.

Why this feels like a hardware store, not just a library

The basic pain point is familiar to anyone who has modeled assemblies by hand. Standard hardware is everywhere, but it is still tedious to redraw a washer, a bearing, or a threaded fastener every time you need one. cq_warehouse treats those parts like inventory: named, parameterized, and ready to place.

That framing matters because it changes the unit of work. You stop thinking in sketches and start thinking in components, dimensions, and reuse. The result is less drafting, fewer one-off models, and more time spent on the parts that actually differentiate the product.

WSJ-style hedcut portrait of gumyr, the maintainer of cq_warehouse. The face is rendered with stipple dots and fine hatching to preserve the likeness from the verified GitHub avatar.

That line is the project in miniature. cq_warehouse does not replace CadQuery. It extends it, which is the more revealing choice. The library sits where standards data, part factories, and CAD ergonomics meet.

A close-up pipeline showing a CSV sheet with rows of imperial fractions and metric dimensions flowing into a normalized geometry engine. On the other side of the pipeline, the rows become clean parametric solids, illustrating how the library separates standards data from shape generation.
The data stays in tables. The geometry stays in Python. That separation is the core architecture.

The real engine: standards in CSV, geometry in Python

The repository leans hard on a CSV-as-database pattern. Fasteners, bearings, sprockets, and related standards live in data files, while Python handles parsing, normalization, and shape construction. That keeps dimensional knowledge separate from geometric logic, which is exactly where a maintainable parts library should draw the line.

The practical payoff is flexibility. Imperial fractions, metric dimensions, and part variants can be updated without rewriting the geometry layer. The code can read a standard, decode it, and hand the numbers to constructors that know how to make the right solid.

The library keeps standards data, parsing, constructors, and kernel work in separate layers so each problem stays legible.

This is why the project feels bigger than a catalog. It is a translation layer. Standards enter as messy real-world data, then emerge as parts that can be used in assemblies, exported to STEP or STL, and regenerated when the design changes.

The weird part is where it gets good

The most interesting file is not the part catalog. It is `extensions.py`. That is where cq_warehouse stops politely using CadQuery and starts extending it. The repo monkey-patches convenience methods onto `Assembly` and `Workplane`, then drops into OCP when CadQuery's surface area is not enough.

A close-up helical thread wrapped around a cylinder, with a tiny tapered zone at the root where extra material prevents a boolean failure. The image explains that the library has to compromise with CAD kernel reality to keep the generated geometry stable.
The hard part is not drawing the thread. It is making the geometry survive boolean operations and manufacturing constraints.

That matters because CAD kernels are forgiving only until they are not. cq_warehouse deals with the brittle edge cases directly: thread fading, text on curved surfaces, projection onto non-planar geometry, and helper methods that make assemblies easier to inspect and count. In other words, it does the unglamorous work that keeps parametric design from breaking on contact with reality.

Threads, bearings, sprockets: where parametric math meets manufacturing reality

The core primitives show the project at full strength. `thread.py` handles helical geometry and the fading logic that softens a thread end before the kernel can complain. `bearing.py` uses a template-like hierarchy for races and rollers. `sprocket.py` turns chain pitch and tooth count into actual radii instead of hand-wavy sketches.

The key detail is that the math is not treated as pure. The code makes room for manufacturing and kernel constraints, including the tiny offsets that help a union succeed when exact geometry would fail. That is the difference between a pretty formula and a tool people can ship with.

WorkflowStandard partsBoilerplateStrengthWeak spot
GUI CADPlaced from catalogs or modeled manuallyLow at first, high at scaleVisual and familiarRepetitive for recurring hardware
Raw CadQueryBuilt from scratch in codeHighFully parametric and scriptableYou still have to model every common part
cq_warehouseNamed constructors backed by standards dataLowRepeatable, assembly-friendly, standard-awareDepends on CadQuery and its kernel layer

That comparison is the point. cq_warehouse does not try to beat a full CAD suite at being a full CAD suite. It removes the dull, standard-part work that slows code-CAD down, then leaves the rest of the assembly to CadQuery.

Why cq_warehouse matters for code-driven mechanical design

The project is quietly infrastructural. It bridges engineering standards, code-first geometry, and the low-level realities of the OCCT kernel without making the user live in any one of those layers for too long. That is a valuable pattern for mechanical software: keep the standards in data, keep the logic in Python, and keep the kernel hacks hidden until they are needed.

That is why cq_warehouse reads like a hardware store built into the language runtime. It makes standard parts feel native to the codebase, and that changes the economics of every assembly built on top of it.