- Python 95.7%
- Shell 4.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Pipeline verification part for the Debian host — exercises export and the 4-view preview without any feature geometry. Sliced and printed on the Centauri Carbon as an end-to-end check. |
||
| parts | ||
| scripts | ||
| .gitignore | ||
| cq | ||
| README.md | ||
| requirements.txt | ||
CadQuery → 3D print workflow
Parametric CAD for the Elegoo Centauri Carbon (256 × 256 × 256 mm build volume).
Describe a part → it gets modelled in CadQuery → reviewed live in CQ-editor → exported print-ready.
Layout
cq launcher (build / show / open / list)
parts/ one .py per part; each defines build()
out/ exports: <name>.step, <name>.3mf, <name>.stl, <name>-preview.png
scripts/build.py export + preview renderer
.venv/ Python 3.13 virtualenv (do not commit)
requirements.txt pinned: cadquery 2.8.0, cq-editor 0.7.0
Usage
./cq build smoke_box # exports STEP + 3MF + STL, renders 4-view preview
./cq show smoke_box # build + print the preview in-terminal
./cq open parts/foo.py # open CQ-editor (live 3D, GPU via XWayland)
./cq list # list parts
A part file is just:
import cadquery as cq
def build():
return cq.Workplane("XY").box(60, 40, 20)
# Required — see the CQ-editor note below.
result = build()
build() may return a cq.Workplane, a cq.Assembly, or any CadQuery Shape.
The result = build() line is not optional. CQ-editor only renders module-level
CadQuery objects: cq_utils.find_cq_objects() scans the module dict for
Workplane / Shape / Assembly / Sketch values. A file that merely defines
build() loads without error and shows a completely empty viewport — which looks
like the geometry broke, not like a missing line.
The review loop
- Describe the change.
- The part file is edited; CQ-editor hot-reloads it (see below) — no restart, no click.
- Review the viewport. A 4-view PNG grid (ISO/TOP/FRONT/RIGHT) is also rendered into chat so the geometry can be checked, not just the fact that the script ran.
- Nothing is exported until the shape is approved.
./cq buildwrites STEP/3MF/STL, so it is the last step, never the first.
Reloading: use File → "Automatic reload and preview". Do not press F5.
render() reads editor.get_text_with_eol() — the editor buffer, not the file on
disk — so after an external edit F5 re-renders the stale geometry and looks like the
change did nothing. "Automatic reload and preview" arms a QFileSystemWatcher;
_file_changed() reads the file into the buffer and emits triggerRerender.emit(True),
re-rendering ~50 ms after each write. With it enabled, an external edit lands in the
viewport on its own. Don't hand-edit in the CQ-editor window while a write is in flight —
the reload replaces the whole buffer.
Export formats
.3mf— feed this to OrcaSlicer. Carries units and colours..step— keep for re-measuring or re-editing the CAD later..stl— universal fallback.
Box angle adjustment — 2026-10-17
parts/box.py tilts the right-hand base downward by 5° about its -Y bottom
edge. The tall plate, rib, and lower hook stay fixed. The material beneath the rib
remains fixed to keep the joint filled and the inner wall continuous.
| Junction angle | Previous | Current |
|---|---|---|
| Top (rib to tapered base top) | 92.86° | 97.86° |
| Bottom (lower tab to base underside) | 135° | 130° |
Validated as one valid solid, with no missing material in the checked region beneath the rib. CQ-editor automatically reloads external file edits; keep using the existing window for review.
Environment notes (why it looks the way it does)
- Python 3.13, on both machines.
cq-editor 0.7.0declaresRequires-Python <=3.14, which in PEP 440 means<=3.14.0— so Fedora's system Python 3.14.8 is rejected outright and the venv must use Fedora'spython3.13package. Debian 13 (trixie) ships Python 3.13 as its defaultpython3, so nothing special is needed there. cadquery2.8.0 has noModelclass. Usecq.Workplane/cq.CQandcq.Assembly. The exporter takesSTL, STEP, AMF, SVG, DXF, TJS, VRML, VTP, 3MF, BREP, BIN.- GPU rendering is preserved. CQ-editor runs on
QT_QPA_PLATFORM=xcb(XWayland) so the Intel iGPU does the work. Headless builds useQT_QPA_PLATFORM=offscreen. Avoid forcingllvmpipe/software GL — it makes the viewport unusable on this hardware. On the Debian container the display is a plain X11 socket (:1.0) that Selkies streams to the browser;xcbis still correct there. - Preview rendering uses VTK 9.6.2 offscreen. Two gotchas already handled:
vtkFeatureEdgesemits point scalars that override actor colour (needsScalarVisibilityOff()), andResetCamera()fits the bounding sphere, which leaves flat parts tiny in a square tile (replaced with a projected-cornerfit_parallel_scale).
Rebuilding the environment
The venv is per-machine and never committed. Two hosts use this repo today: a Fedora laptop and a Debian 13 (trixie) LXC container whose desktop is streamed to the browser by Selkies.
Fedora (laptop)
sudo dnf install -y python3.13 # 3.14 is incompatible, see above
python3.13 -m venv .venv
.venv/bin/pip install -r requirements.txt
Debian 13 / trixie (LXC + Selkies)
Python 3.13 is the distro default here, so only two X11-era packages are missing:
sudo apt-get update
sudo apt-get install -y chafa libxcb-xinerama0
python3.13 -m venv .venv
.venv/bin/pip install -r requirements.txt
-
libxcb-xinerama0is the one that bites. Without it,QT_QPA_PLATFORM=xcbfails withCould not load the Qt platform plugin "xcb"and CQ-editor never opens — the message blames Qt, not the missing library. Confirm with:ldd .venv/lib/python3.13/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so | grep "not found" -
chafais only used by./cq show;./cq buildworks without it. -
PyPI ships cp313 manylinux wheels for
cadquery-ocpandvtk, so this is a download, not a compile. Expect ~2 GB installed.