@rulecad/printcheck
Is this mesh printable? Bed size, overhangs, bridges, floating undersides and closed solids, in plain words.
npm install @rulecad/printcheck
Try it
Checked against a Bambu X1C: 256 mm bed, 45° overhangs, 5 mm bridges.
Reference
Is this mesh printable on an FDM printer? Hand it triangles and your printer's limits; get back findings in plain words. No dependencies; browsers and Node 20+.
import { check } from '@rulecad/printcheck';
const printer = { bed: 256, overhang: 45, layer: 0.2, support_gap: 0.2, bridge: 5, line: 0.42, print_gap: 0.3, foot: 0.15 };
const findings = check(triangles, printer);
// [{ level: 'pass', text: '20 × 4 × 12 mm, fits the bed' },
// { level: 'warn', text: 'an underside at z 10 starts in mid-air: needs support …' }, …]
triangles is [[[x, y, z], [x, y, z], [x, y, z]], …] in millimetres, Z up, the bed at z = 0: the model is checked as it will print, so its orientation is part of the design. Any CAD library's output works once triangulated.
What it checks:
- Fits the bed (
bed, mm) and sits on it: lowest point at z = 0, with faces flat on the bed. - Overhangs steeper than
overhangdegrees from vertical (with half a degree to spare: a boolean tips a 45° chamfer by hundredths of a degree). This measures the sloped faces; flat undersides are left to the checks below, and the tick says so ("no sloped overhangs past 45°; flat undersides are checked on their own"). When the part is sliced (layergiven), the layers decide and the faces' figure is a note. Neither overhang check gives a tick when a finding after it says part of the print needs support (a ledge, a bridge too wide, an underside or island in mid-air): the tick becomes a note (info) that says so. The faces' tick becomes a note too when the sliced layers lean past the limit. - Inside out: a mesh whose faces all point inwards (corners running clockwise seen from outside) fails as that, before anything else is read from it.
- Flat undersides above the bed: each must start on something. Either it rests on a built-in breakaway support (one
support_gapbelow a surface), or it bridges no wider thanbridgemm. The bridge is the widest circle that fits in the underside, measured to the edges held up by material below. An underside held by nothing starts in mid-air. One held on one side only (its supports all within a half turn of it, and a little), further out than a print line, is a ledge: nothing bridges it, each line is laid past the last in the air, and it droops (slant its underside in at 45° to the wall instead). A hole in an underside whose edge nothing holds, such as the ring round the screw's hole in a counterbore opening on the bed, is a ledge too: no line is laid across the hole, and the line round it hangs out from the held edge, so it reaches the ring's width. An underside that is a bridge taken whole, its hole filled in (a nut slot's roof with the screw's hole up through it: lines run wall to wall past the hole), is still a bridge, as wide as it is; so is a counterbore whose seat is no wider thanbridge. A seat roofed over by a layer printed across it (drilled out afterwards) is a bridge as wide as the seat. What lies within a breakaway gap or two layers of the bed, or of a surface below it, rests on it. Undersides within a layer of each other are one height; what starts in mid-air and what hangs as a ledge is said once per height, with how many and the worst, and where. Each underside is taken on its own (the faces at a height joined where they touch), and an edge is held wherever it lies along the top edge of a wall below (booleans leave T-junctions; they don't matter). An underside no wider than a print line (line, 0.42 mm unless given) anywhere is a step of a slope printed in layers, or a sliver the slicer lays nothing on, and is not counted. - The first layer: two parts printed in place must stand
print_gapplus twicefootapart on the bed (footis how far the first layer spreads each side as it is squashed on: elephant's foot); nearer, they print as one. Checked when the printer gives both; lifting one part a layer off the bed takes it out of the check. - Islands, as the slicer sees them: the mesh cut at every layer (
layer), each layer's regions against the one below within the overhang reach; a region with nothing under it is an island the printer would lay on air. Drawn on a grid of the print line (line), so slivers narrower than a line don't count. Also exported asislands(), with each island's pixels for whatever fixes it. - Overhang, as the slicer sees it: the area of each layer lying out past what the layer below holds (at
overhangdegrees and a line), and past what the layers 5 and 20 below allow, so a long lean is held near the limit. The layer just over a flat underside that the checks above judge (a bridge, a ledge, a breakaway support) is left out of it there, and only there: bridges in one place hide nothing anywhere else. A step of a slope narrower than a line is not left out: the slope is this check's to judge. - Closed solid: every edge is matched by a face on the other side. T-junctions count as closed, and so do hairline seams narrower than
HAIRLINE(0.01 mm), which booleans leave and no printer can resolve. Wider gaps are holes. - One piece: a loose piece would print as a stray bit or fall over. A cavity inside a part (its surface faces in) isn't a piece.
- Nothing starting in mid-air: the lowest point of a tip hanging down (an icicle), with nothing below it to print on. Its faces point down, and for a millimetre above it the surface stays narrow. The face-by-face overhang check misses a tip like this, because each of its faces may slope at 45° or less. A shallow dip in a smoothed underside spreads wide, so it doesn't count.
The layer checks (islands, the first layer, overhang as sliced) are the slow part, seconds on a curved part: check(triangles, printer, { slice: false }) leaves them out and says so (print.unsliced), for a page that shows a part at once and slices it off its own thread (the viewer does).
Several parts printed together (a keycap with an inlaid legend in another colour): pass { parts: [{ triangles, role }] }. Then one part resting on another isn't an overhang, and each part must be closed on its own. A part with role: 'support' is printed and then removed.
Also exported: bounds(triangles) ({ lo, hi, size }), seams(triangles) ({ gaps, tjunctions, hairlines }), shape(triangles) ({ pieces, tips }), widest(polys, held, under) (the bridge measurement) and ledges(polys, held, under) (how far an underside reaches past its last support).