Skip to content

wholeboard.enclosure

3D-printable enclosures, designed by the AI and built in FreeCAD.

The flow: 1. context() reads the finished board and lists what an enclosure designer needs: board size, mounting holes, and every part with its position, estimated height and nearest edge. 2. The AI writes an enclosure spec (see SPEC_DOC), starting from suggest() if it likes. 3. validate() checks the spec. resolve() turns it into exact geometry: every box, cylinder and cut in enclosure coordinates. 4. build() runs FreeCAD's command-line mode on freecad_enclosure.py with that geometry. FreeCAD builds the base and lid, checks every part against them for collisions and exports STEP, STL and a FreeCAD document.

Board coordinates (what the AI uses): x_mm right and y_mm down from the board's top-left corner, like component placements. Enclosure coordinates (inside FreeCAD): X right, Y towards the board's top edge, Z up from the bottom of the base, in millimetres.

classify(fp_id, tht, height_override=None)

Estimate a part's height and what the enclosure should do for it.

context(geo, spec, part_heights=None)

What the AI needs to design an enclosure, in board coordinates (mm from the top-left).

public_context(ctx)

The context without internal fields, for the AI.

suggest(ctx)

A sensible starting enclosure the AI can adjust.

resolve(ctx, enc)

Turn the AI's enclosure spec into exact solids for FreeCAD (enclosure coordinates).

find_freecad(cfg=None)

The command that runs FreeCAD without a window (as a list), or None.

read_stl(path)

Read an STL (binary or ASCII) into shared vertices and triangle indices.

build(geo, spec, enc, out_dir, name, cfg=None, log=print, cancel=None)

Validate the AI's enclosure, build it in FreeCAD and return a summary with any problems.

print_estimate(volume_mm3, settings=None)

Filament, time and cost to print the base and lid at home.

The solid volume is mostly walls, which slicers print as solid perimeters, so grams follow the volume; time follows the volumetric rate the printer sustains plus heat-up per part.

fetch_freecad(log=print)

Download the latest stable FreeCAD for this machine; returns the command that runs it.