TinkerIndustries

Turret

An Electron application that hosts Claude Code sessions, with modes.

CAD mode is for designing a part in code. You write Python that returns solids. Turret builds it, draws it on screen, measures it, and checks whether it would print.

What a design is

A design is a folder with a design.toml file in it. That file names the Python function which builds the geometry. It also writes down what the design produces: the separate parts, the parameters someone is allowed to change, which way up each part prints, and the checks it has to pass.

The Python is yours and lives in your own repository, laid out however suits it. The one thing required is a function that takes the parameters as arguments and hands back one solid per part. There is no class to inherit from, no filename to match, and nothing to import from Turret.

The build

Building runs your function in a separate process and freezes what comes back as a snapshot: one set of parameter values, one form of every part. The snapshot is what the viewer draws and what every measurement reads. Nothing measures your source code.

Each build writes a build/ folder beside your code holding a STEP and an STL for every part, the results of the checks, and everything the generator printed while it ran. That log is the first thing to read when a build fails. The folder is machine-written and churns on every build, so keep it out of version control.

The loop

StepWhat happens
RegisterThe folder is named to the app once and given a short slug. Every later request goes through that slug.
BuildYour function runs with the parameters you asked for, and what it returns becomes the snapshot.
ViewThe snapshot goes on screen in the viewer, in a tab of its own.
Edit and build againChange the Python, build, look at what moved.

Registering happens once per folder and a second attempt is refused. Nothing from design.toml is stored anywhere, so an edit to the parameters, the parts or the checks is live on the very next call. A design that is registered and never built is a name and a path, and opening it in the viewer says so.

On screen

The viewer holds a tab per design, and the + button on the tab strip opens another. You move the camera, hide the parts you are not interested in, and draw shapes directly on the model.

Marking a face is usually quicker than describing one. Say “widen this hole” and the session reads where your camera is, which parts you can actually see, and every shape you have drawn with its face and its coordinates in millimetres. Your marks are then drawn over the pictures it renders for itself, each under the name you gave it.

Looking and measuring

Pictures come back from a camera you choose, or as a cropped detail, a cutaway or a cross section. Numbers come from the solid: distances between features, a list of faces, a probe at a point, the space between two parts, whether two parts run into each other.

A design that produces a STEP file per part can be measured exactly. A design that only produces meshes gets an answer of “cannot say” from the tools that need exact geometry, rather than an estimate.

Whether it would print

The checks cover wall thickness, hole size, overhangs, bridges, whether the part fits the bed, and whether anything is left unmanifold. A rule pack of the usual FDM rules is four lines to switch on. Beyond that you write checks specific to the design, each with the result it expects.

What a pass means

The checks measure the CAD solid against handbook figures for a nozzle and a material. None of them sees bead spread, shrinkage, warp, or what a slicer would do with a thin wall. A pass means the geometry clears the rule. It is not a promise that the print comes out well.

Which way up a part prints

Every part declares the axis that points up on the plate, or says that it is not printed at all. Model the part sitting the way it prints, or model it in place in an assembly, as long as the geometry and the declared direction agree. Get them out of step and the part is rotated twice, and every rule that depends on orientation is then measured against a pose the part will never print in.

There is a third option, meaning the decision has not been made yet. It fails the build for that part, which is the point. An undecided orientation blocks rather than defaults.

The Python you can use

Your generator runs under an interpreter Turret installs for itself, holding the OpenCascade binding, numpy, shapely and the standard library. cadquery, build123d and trimesh are not in it.

A script written against one of those has two ways forward. Port the geometry to the raw OpenCascade binding, or keep the script running wherever it already runs and have it drop its geometry into a folder for Turret to pick up. The second one is the answer when the generator needs FreeCAD, another interpreter, or another machine.

Starting out

A band across the top of a CAD session installs that interpreter the first time you need it. A second band writes a design guide into the repository: templates for design.toml, the full field reference, the rules for writing checks, and a script that calls your generator and reports each part’s size, volume, solid count and validity. Run that script before registering anything. It is the quickest way to notice that a part is a thousand times too big because a millimetre was read as a metre.

The band comes back after a Turret update when the copy in the repository has fallen behind.

Where it stops

A CAD session produces geometry. Nothing in it plates a part, slices one, or reaches a printer.