rulecad

Design physical things as code, where every measurement says which rule it comes from: a printer's line width, a screw's clearance, a switch's stem. Check that they print and fit, version them by what fits what, draw their circuit boards from the same rules, and share them as links.

npm create rulecad@latest my-project
cd my-project && npx cad check home/soap-tray

Each library below has a page: what it is for, how to use it, and a demonstration. The ones marked live run their own code in this page.

Guides

Walked from start to finish, in commands.

guide

Frames: from a spec sheet to a checked box

guide

Machines: from a task to a drawing

guide

Choosing a pilot, an insert or a nut

Design

Describe a part by its rules and check it.

@rulecad/cad

cad

The command line at the centre: every measurement a variable with its rule, checks for printing and fit, previews, print files and links.

create-rulecad

create-rulecad

Start a project: a workspace with a printer's rules, a starter design and the notes an AI agent needs.

@rulecad/variables · live

variables

Variables that say where each number comes from: expressions over rule sets, resolved, and a lint that keeps numbers out of code.

@rulecad/rules · live

rules

Published facts: printers, screws, switches, fabs and parts, each value with its source and the date it was checked.

@rulecad/shapes · live

shapes

Shape helpers for printed parts: text that prints, anchors on a face, clean cuts, and an enclosure kit.

@rulecad/fixings · live

fixings

Screws, nuts and inserts by name: holes sized by what they are for, seats that print, threads cut for printing, and the sums on a joint. cad, motors and pcb take every screw size from it.

@rulecad/frames · live

frames

Structures from beams: profiles of any maker as rule sets, beams and the joins between them, slot nuts, printed and bought fittings, guides for motion, printed beams, frames generated from a size, the cut list, sheets and jigs, and building square.

@rulecad/flexures · live

flexures

Parts that move by bending: leaf springs, guides, serpentine springs and notch hinges, each with its stiffness, its strain, and how it prints.

@rulecad/topopt · live

topopt

Topology optimisation for flat and solid parts: the stiffest layout of the material you give, or the lightest under a stress limit, printable without supports if asked.

@rulecad/versions · live

versions

Semver for physical parts: a major release means an earlier print may no longer fit.

Check

Will it print? Does it fit?

@rulecad/printcheck · live

printcheck

Is this mesh printable? Bed size, overhangs, bridges, floating undersides and closed solids, in plain words.

@rulecad/fit · live

fit

Do these parts fit? The smallest gap between two meshes, and whether a point is inside one.

Boards

Circuit boards from the same rules.

@rulecad/pcb

pcb

Circuit boards from the same rules: parts from rule sets or KiCad footprints, nets, routing, any board shape, fab files.

Share

A model in a link, and the page that opens it.

@rulecad/model-link · live

model-link

A model in a link: compressed into the URL fragment, never uploaded; STL and Bambu-ready 3MF made in the browser.

@rulecad/viewer

viewer

The model page: opens model links, checks dropped STL files, writes print files. Plain static files you can host anywhere.

Keyboards

One layout file for plate, keycaps, case and board.

@rulecad/keyboard-layout · live

keyboard-layout

One layout file that the plate, keycaps, case and board all read; and an importer for keyboard-layout-editor.com.

Machines

Arms and axes as plain data: where they reach and how they draw.

@rulecad/robots · live

robots

Arms and axes as plain data: forward and inverse kinematics, the Jacobian, reach over a sheet, and an SVG drawing turned into joint moves and step blocks.

How they fit together

cad is the command line. It reads designs whose variables come from variables and rule sets such as rules, builds shapes with JSCAD and shapes, sizes holes and seats for screws with fixings, builds frames from aluminium beams with frames, checks them with printcheck and fit, releases them with versions, lays out keyboards with keyboard-layout, draws boards with pcb, and shares them with model-link, which the viewer opens. create-rulecad starts a project with all of it in place.