CadQuery parametric parts for the Elegoo Centauri Carbon - describe/model/review loop with CQ-editor previews
  • Python 95.7%
  • Shell 4.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
minnix d44411043b Add test_box: flat 180 x 40 x 2 mm plate
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.
2026-10-20 11:51:43 -05:00
parts Add test_box: flat 180 x 40 x 2 mm plate 2026-10-20 11:51:43 -05:00
scripts CadQuery part workflow + compost_adapter prototype 2026-10-11 20:11:49 -05:00
.gitignore Ignore core dumps from crashed Qt runs 2026-10-20 11:18:54 -05:00
cq Ignore core dumps from crashed Qt runs 2026-10-20 11:18:54 -05:00
README.md Document Debian 13 setup alongside the Fedora path 2026-10-20 11:14:22 -05:00
requirements.txt CadQuery part workflow + compost_adapter prototype 2026-10-11 20:11:49 -05:00

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

  1. Describe the change.
  2. The part file is edited; CQ-editor hot-reloads it (see below) — no restart, no click.
  3. 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.
  4. Nothing is exported until the shape is approved. ./cq build writes 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.0 declares Requires-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's python3.13 package. Debian 13 (trixie) ships Python 3.13 as its default python3, so nothing special is needed there.
  • cadquery 2.8.0 has no Model class. Use cq.Workplane / cq.CQ and cq.Assembly. The exporter takes STL, 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 use QT_QPA_PLATFORM=offscreen. Avoid forcing llvmpipe/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; xcb is still correct there.
  • Preview rendering uses VTK 9.6.2 offscreen. Two gotchas already handled: vtkFeatureEdges emits point scalars that override actor colour (needs ScalarVisibilityOff()), and ResetCamera() fits the bounding sphere, which leaves flat parts tiny in a square tile (replaced with a projected-corner fit_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-xinerama0 is the one that bites. Without it, QT_QPA_PLATFORM=xcb fails with Could 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"
    
  • chafa is only used by ./cq show; ./cq build works without it.

  • PyPI ships cp313 manylinux wheels for cadquery-ocp and vtk, so this is a download, not a compile. Expect ~2 GB installed.