3. Inspect and export the parts
Before adding hardware, measure the model and produce files for each part. You will use the names introduced in the previous chapter.
Inspect a part
Run:
uv run cadkit --project enclosure:PROJECT inspect box
uv run cadkit --project enclosure:PROJECT inspect lid
Both commands build the selected part and print geometry measurements as JSON. The box has outer dimensions 80 × 50 × 20 mm and volume approximately 20,176.896 mm³. The lid has dimensions 80 × 50 × 3 mm and volume 12,000 mm³. The box volume is smaller than a solid 80 × 50 × 20 block because of its cavity.
In the app, select the box and lid together with Shift-click. Their minimum distance appears automatically in the inspector. It should be 0 mm because their surfaces meet at the rim. A zero distance alone does not prove that parts are correctly fitted: it also occurs when solids overlap. You will declare the intended contact in chapter 5.
Export both parts
Open build/enclosure. It contains box.stl, box.step, lid.stl, lid.step
and manifest.json, together with quantity and group metadata. The manifest
records measurements, file names and hashes. STL is a mesh for workflows such
as slicing; STEP preserves the native solid geometry.
Each part is exported independently in its manufacturing orientation. CadKit moves its lowest Z coordinate onto the build plane. In the box's STEP file, the floor is therefore at Z = 0 even though its authored floor is at Z = −20. The assembled arrangement is a separate output:
uv run cadkit --project enclosure:PROJECT assembly --output build/enclosure-assembled.step
uv run cadkit --project enclosure:PROJECT assembly --exploded --output build/enclosure-exploded.step
The first keeps the lid on the rim. The second lifts the lid by its 20 mm
explode offset, without changing either part definition.
Keep a runnable export script
Add this entry point after PROJECT = DESIGN.as_project() if you want
uv run python enclosure.py to export both parts:
if __name__ == "__main__":
from cadkit.export import build
build(PROJECT, PROJECT.select(["all"]), "build/enclosure")
Importing this file in the app still only exposes PROJECT; it does not write
exports. The command-line entry point calls the same exporter used by
cadkit build.
To start at this chapter, copy the complete snapshot into enclosure.py.
Complete project with export command: enclosure.py
"""Chapter 3: export the two parts. Importing the file does not write files."""
import cadquery as cq
WIDTH = 80
DEPTH = 50
HEIGHT = 20
WALL = 2.4
LID_THICKNESS = 3
def box_body():
# The rim is Z=0; the box extends down from it.
outside = cq.Workplane("XY").rect(WIDTH, DEPTH).extrude(-HEIGHT)
cavity = (cq.Workplane("XY").rect(WIDTH - 2 * WALL, DEPTH - 2 * WALL)
.extrude(-(HEIGHT - WALL)))
return outside.cut(cavity)
def lid_body():
return cq.Workplane("XY").rect(WIDTH, DEPTH).extrude(LID_THICKNESS)
import cadkit as ck
BOX = ck.Part("box", box_body, manufacture=ck.FDM("PETG"))
LID = ck.Part("lid", lid_body, manufacture=ck.FDM("PETG"))
DESIGN = ck.Assembly("enclosure")
box = DESIGN.add("box", BOX, color=(0.32, 0.58, 0.72))
lid = DESIGN.add("lid", LID, color=(0.86, 0.70, 0.40), explode=(0, 0, 20))
DESIGN.fix(box)
DESIGN.fix(lid)
PROJECT = DESIGN.as_project()
if __name__ == "__main__":
from cadkit.export import build
build(PROJECT, PROJECT.select(["all"]), "build/enclosure")
Complete example · ← Make a project · Next: fasten the lid →
