An inline fan box
A fan box sits in a ceiling void between two ducts. Air arrives through a rectangular duct at one end, a fan inside pushes it on, and it leaves upward through a round spigot into the riser. It is a product almost every sheet metal shop makes in some form, and it needs nearly everything the shop can do: a folded casing whose corners are closed, edges made safe and stiff, ventilation and stiffening pressed into flat panels, threads for screws drawn out of a 1 mm sheet, a transition from a square duct to a round one, a smoothly curved vane, and brackets to hang it by.
That is why it is the showcase for this section: one recognisable product whose every part is sheet metal, built in one script with every operation of bitbybit.occt.fabrication.sheetMetal used where a fabricator would use it. The lid and the outlet are drawn lifted above the casing so the inside can be seen, and all ten parts are drawn in their looks, as one list with the sheet drawing options: the bends tinted, the forms in the accent and the sheets' edges thin.




- Rete
- Blockly
- TypeScript
const { sheetMetal } = bitbybit.occt.fabrication;
const { face, wire } = bitbybit.occt.shapes;
const { sheetMetalBendDirectionEnum, sheetMetalClosureEnum, sheetMetalContourSideEnum, sheetMetalCornerKindEnum, sheetMetalCornerReliefEnum, sheetMetalFixedSideEnum, sheetMetalFoldPositionEnum, sheetMetalFormEnum, sheetMetalHemStyleEnum, sheetMetalLoftMethodEnum, sheetMetalLoftSideEnum } = Bit.Inputs.OCCT;
type Part = Bit.Models.OCCT.SheetPart<Bit.Inputs.OCCT.TopoDSShapePointer>;
type Point = Bit.Inputs.Base.Point3;
type Vector = Bit.Inputs.Base.Vector3;
const up: Vector = [0, 1, 0];
const inside = (part: Part, region: string) => sheetMetal.insideFace({ part, region });
const edgeToward = (part: Part, region: string, direction: Vector) => sheetMetal.insideEdgeToward({ part, region, direction });
const hole = (center: Point, diameter: number, direction: Vector) => wire.createCircleWire({ center, radius: diameter / 2, direction });
const rounded = async (width: number, length: number, center: Point, direction: Vector, radius: number) =>
bitbybit.occt.fillets.fillet2d({ shape: await wire.createRectangleWire({ width, length, center, direction }), radius });
// The casing: a floor, four mitred walls, lips and hems along their tops
const floorFace = await face.createRectangleFace({ width: 300, length: 200, center: [0, 0, 0], direction: up });
let casing = await sheetMetal.plate({ face: floorFace, thickness: 1, bendRadius: 1, cornerRelief: sheetMetalCornerReliefEnum.circular, name: "floor" });
casing = await sheetMetal.flanges({
part: casing,
insideFace: await inside(casing, "floor"),
edges: [await edgeToward(casing, "floor", [-1, 0, 0]), await edgeToward(casing, "floor", [1, 0, 0]), await edgeToward(casing, "floor", [0, 0, -1]), await edgeToward(casing, "floor", [0, 0, 1])],
length: 150,
name: "wall",
});
const inletWall = "wall";
const backWall = "wall.2";
const louvredWall = "wall.3";
const panelWall = "wall.4";
casing = await sheetMetal.flange({ part: casing, insideFace: await inside(casing, louvredWall), edge: await edgeToward(casing, louvredWall, up), length: 15, extentStart: 6, extentEnd: 6, name: "lip1" });
casing = await sheetMetal.flange({ part: casing, insideFace: await inside(casing, panelWall), edge: await edgeToward(casing, panelWall, up), length: 15, extentStart: 6, extentEnd: 6, name: "lip2" });
casing = await sheetMetal.hem({ part: casing, insideFace: await inside(casing, inletWall), edge: await edgeToward(casing, inletWall, up), style: sheetMetalHemStyleEnum.closed, extentStart: 6, extentEnd: 6, name: "hem1" });
casing = await sheetMetal.hem({ part: casing, insideFace: await inside(casing, backWall), edge: await edgeToward(casing, backWall, up), style: sheetMetalHemStyleEnum.teardrop, extentStart: 6, extentEnd: 6, name: "hem2" });
// Openings and holes
const inletOpening = await wire.createRectangleWire({ width: 100, length: 180, center: [-149, 75, 0], direction: [1, 0, 0] });
const collarBolts = await Promise.all([[15, -60], [15, 60], [135, -60], [135, 60], [75, -100], [75, 100]].map(([y, z]) => hole([-149, y, z], 5, [1, 0, 0])));
casing = await sheetMetal.cut({ part: casing, face: await inside(casing, inletWall), profiles: [inletOpening, ...collarBolts] });
const bracketHoles = (z: number) => Promise.all([[-125, 70], [-125, 100], [125, 70], [125, 100]].map(([x, y]) => hole([x, y, z], 4.5, [0, 0, 1])));
casing = await sheetMetal.cut({ part: casing, face: await inside(casing, louvredWall), profiles: await bracketHoles(-99) });
casing = await sheetMetal.cut({ part: casing, face: await inside(casing, panelWall), profiles: await bracketHoles(99) });
// Stamped forms
casing = await sheetMetal.form({ part: casing, face: await inside(casing, "floor"), kind: sheetMetalFormEnum.dimple, points: [[-125, 0, -80], [125, 0, -80], [-125, 0, 80], [125, 0, 80]], diameter: 16, depth: 3, draft: 30, direction: sheetMetalBendDirectionEnum.down, name: "foot" });
casing = await sheetMetal.form({ part: casing, face: await inside(casing, "floor"), kind: sheetMetalFormEnum.extrudedHole, points: [[-60, 0, -50], [20, 0, -50], [-60, 0, 50], [20, 0, 50]], diameter: 5, height: 3, direction: sheetMetalBendDirectionEnum.down, name: "mount" });
const beads = [await wire.createLineWire({ start: [-110, 0, -75], end: [60, 0, -75] }), await wire.createLineWire({ start: [-110, 0, 75], end: [60, 0, 75] })];
casing = await sheetMetal.form({ part: casing, face: await inside(casing, "floor"), kind: sheetMetalFormEnum.bead, curves: beads, width: 8, depth: 2, draft: 30, bendRadius: 0.5, name: "bead" });
casing = await sheetMetal.form({ part: casing, face: await inside(casing, "floor"), kind: sheetMetalFormEnum.bridge, points: [[115, 0, -40], [115, 0, 40]], along: [0, 0, 1], length: 24, width: 6, height: 3, name: "tie" });
casing = await sheetMetal.form({ part: casing, face: await inside(casing, louvredWall), kind: sheetMetalFormEnum.louver, points: [[40, 50, -99], [40, 70, -99], [40, 90, -99], [40, 110, -99]], along: [1, 0, 0], length: 50, width: 8, height: 3, direction: sheetMetalBendDirectionEnum.down, name: "louver" });
const panel = await rounded(90, 150, [-15, 75, 99], [0, 0, 1], 10);
casing = await sheetMetal.form({ part: casing, face: await inside(casing, panelWall), kind: sheetMetalFormEnum.emboss, curves: [panel], depth: 3, draft: 30, direction: sheetMetalBendDirectionEnum.down, name: "panel" });
casing = await sheetMetal.form({ part: casing, face: await inside(casing, "lip1"), kind: sheetMetalFormEnum.extrudedHole, points: [[-100, 148, -92], [100, 148, -92]], diameter: 3.5, height: 3, name: "thread1" });
casing = await sheetMetal.form({ part: casing, face: await inside(casing, "lip2"), kind: sheetMetalFormEnum.extrudedHole, points: [[-100, 148, 92], [100, 148, 92]], diameter: 3.5, height: 3, name: "thread2" });
casing = await sheetMetal.lance({ part: casing, insideFace: await inside(casing, backWall), from: [149, 40, -60], to: [149, 40, -40], depth: 10, name: "hook" });
casing = await sheetMetal.gusset({ part: casing, across: "wall.b2", positions: [40, 150], width: 10, depth: 3 });
// The lid: four skirts whose corners are closed by overlaps
let lid = await sheetMetal.plate({ face: await face.createRectangleFace({ width: 303, length: 203, center: [0, 149, 0], direction: [0, -1, 0] }), thickness: 1, bendRadius: 1, name: "top" });
for (const [name, direction] of [["inletSkirt", [-1, 0, 0]], ["backSkirt", [1, 0, 0]], ["skirt1", [0, 0, -1]], ["skirt2", [0, 0, 1]]] as const) {
lid = await sheetMetal.flange({ part: lid, insideFace: await inside(lid, "top"), edge: await edgeToward(lid, "top", [...direction]), length: 20, extentStart: 5, extentEnd: 5, name });
}
const overlap = async (part: Part, first: string, firstToward: Vector, second: string, secondToward: Vector) => sheetMetal.closeCorner({
part,
firstInsideFace: await inside(part, first),
firstEndFace: await sheetMetal.endFaceToward({ part, region: first, direction: firstToward }),
secondInsideFace: await inside(part, second),
secondEndFace: await sheetMetal.endFaceToward({ part, region: second, direction: secondToward }),
kind: sheetMetalClosureEnum.overlap,
});
lid = await overlap(lid, "skirt1", [-1, 0, 0], "inletSkirt", [0, 0, -1]);
lid = await overlap(lid, "skirt2", [-1, 0, 0], "inletSkirt", [0, 0, 1]);
lid = await overlap(lid, "skirt2", [1, 0, 0], "backSkirt", [0, 0, 1]);
lid = await overlap(lid, "skirt1", [1, 0, 0], "backSkirt", [0, 0, -1]);
const outletOpening = await wire.createRectangleWire({ width: 160, length: 110, center: [60, 149, 0], direction: up });
const lidScrews = await Promise.all([[-100, -92], [100, -92], [-100, 92], [100, 92]].map(([x, z]) => hole([x, 149, z], 4.5, up)));
lid = await sheetMetal.cut({ part: lid, face: await inside(lid, "top"), profiles: [outletOpening, ...lidScrews] });
const label = await rounded(60, 30, [-90, 150, 0], up, 3);
lid = await sheetMetal.cut({ part: lid, face: await sheetMetal.outsideFace({ part: lid, region: "top" }), profiles: [label], depth: 0.4, name: "label" });
lid = await sheetMetal.rip({ part: lid, insideFace: await inside(lid, "backSkirt"), from: [150.5, 125, 40], to: [150.5, 138, 40], gap: 6, name: "cableSlot" });
// The outlet: a square-to-round transition on the lid
const square = await wire.createRectangleWire({ width: 160, length: 110, center: [60, 150, 0], direction: up });
const round = await wire.createCircleWire({ radius: 62.5, center: [60, 230, 0], direction: up });
const spigot = await sheetMetal.loft({ first: square, second: round, thickness: 1, bendRadius: 1, side: sheetMetalLoftSideEnum.outside, facetsPerBend: 16, name: "spigot" });
// The turning vane: one smooth formed region
const vaneStart = await wire.createPolylineWire({ points: [[20, 15, -97], [110, 15, -97], [110, 140, -97]] });
const vaneEnd = await wire.createPolylineWire({ points: [[20, 15, 97], [110, 15, 97], [110, 140, 97]] });
const vane = await sheetMetal.loft({ first: vaneStart, second: vaneEnd, thickness: 1, method: sheetMetalLoftMethodEnum.formed, filletRadius: 60, name: "vane" });
// The DIN rail for the speed controller, a top-hat contour with slots
const hat = await wire.createPolylineWire({ points: [[149, 100, 0], [149, 95, 0], [141.5, 95, 0], [141.5, 70, 0], [149, 70, 0], [149, 65, 0]] });
let rail = await sheetMetal.contour({ profile: hat, direction: [0, 0, 1], length: 120, thickness: 1, side: sheetMetalContourSideEnum.right, symmetric: true, bendRadius: 1, name: "rail" });
const railSlots = await Promise.all([-50, -25, 0, 25, 50].map((z) => rounded(15, 5.2, [141.5, 82.5, z], [1, 0, 0], 2.5)));
rail = await sheetMetal.cut({ part: rail, face: await inside(rail, "rail.3"), profiles: railSlots });
// The duct collar on the inlet, an angle swept round a rectangle
const collarPath = await wire.createPolylineWire({ points: [[-150, 25, -90], [-150, 25, 90], [-150, 125, 90], [-150, 125, -90], [-150, 25, -90]] });
const collarProfile = await wire.createPolylineWire({ points: [[-180, 25, -90], [-150, 25, -90], [-150, 5, -90]] });
let collar = await sheetMetal.sweep({ profile: collarProfile, path: collarPath, thickness: 1, bendRadius: 1, side: sheetMetalContourSideEnum.right, name: "collar" });
const collarHoles = await Promise.all([[15, -60], [15, 60], [135, -60], [135, 60], [75, -100], [75, 100]].map(([y, z]) => hole([-150, y, z], 5, [1, 0, 0])));
collar = await sheetMetal.cut({ part: collar, face: await inside(collar, "collar"), profiles: collarHoles });
// A hanger bracket: two plates joined, jogged, folded, then finished
const leg = await sheetMetal.plate({ face: await face.createRectangleFace({ width: 70, length: 30, center: [125, 85, -101.5], direction: [0, 0, -1] }), thickness: 1.5, bendRadius: 1.5, name: "leg" });
const arm = await sheetMetal.plate({ face: await face.createRectangleFace({ width: 30, length: 85, center: [125, 121.5, -145.5], direction: [0, -1, 0] }), thickness: 1.5, bendRadius: 1.5, name: "arm" });
let bracket = await sheetMetal.join({
first: leg,
firstInsideFace: await inside(leg, "leg"),
firstEdge: await edgeToward(leg, "leg", up),
second: arm,
secondInsideFace: await inside(arm, "arm"),
secondEdge: await edgeToward(arm, "arm", [0, 0, 1]),
name: "elbow",
});
bracket = await sheetMetal.bend({ part: bracket, insideFace: await inside(bracket, "arm"), from: [110, 121.5, -112], to: [140, 121.5, -112], angle: 90, offset: 40, direction: sheetMetalBendDirectionEnum.down, position: sheetMetalFoldPositionEnum.bendOutside, fixed: sheetMetalFixedSideEnum.right, name: "rise" });
bracket = await sheetMetal.bend({ part: bracket, insideFace: await inside(bracket, "rise.2"), from: [110, 161.5, -142], to: [140, 161.5, -142], angle: 90, fixed: sheetMetalFixedSideEnum.right, name: "lip" });
const ear = await face.createRectangleFace({ width: 22, length: 16, center: [148, 161.5, -126], direction: [0, -1, 0] });
bracket = await sheetMetal.tab({ part: bracket, insideFace: await inside(bracket, "rise.2"), tab: ear });
const rodSlot = await rounded(9, 16, [125, 161.5, -127], up, 4);
bracket = await sheetMetal.cut({ part: bracket, face: await inside(bracket, "rise.2"), profiles: [rodSlot, await hole([151, 161.5, -126], 5, up)] });
bracket = await sheetMetal.gusset({ part: bracket, across: "elbow.b1", positions: [15], width: 8, depth: 3 });
bracket = await sheetMetal.roundCorners({ part: bracket, insideFace: await inside(bracket, "leg"), size: 5, kind: sheetMetalCornerKindEnum.convex });
bracket = await sheetMetal.cut({ part: bracket, face: await inside(bracket, "leg"), profiles: [await hole([125, 70, -101.5], 4.5, [0, 0, 1]), await hole([125, 100, -101.5], 4.5, [0, 0, 1])] });
// Three mirrored copies of the bracket, and the lid and outlet lifted to show the inside
const mirror = (normal: Vector) => bitbybit.occt.transforms.mirrorPlaneToMatrix({ origin: [0, 0, 0], normal });
const otherEnd = await sheetMetal.transform({ part: bracket, transformation: await mirror([1, 0, 0]) });
const otherSide = await sheetMetal.transform({ part: bracket, transformation: await mirror([0, 0, 1]) });
const otherCorner = await sheetMetal.transform({ part: otherEnd, transformation: await mirror([0, 0, 1]) });
const lift = await bitbybit.occt.transforms.translationToMatrix({ translation: [0, 140, 0] });
const liftedLid = await sheetMetal.transform({ part: lid, transformation: lift });
const liftedSpigot = await sheetMetal.transform({ part: spigot, transformation: lift });
for (const [name, part] of Object.entries({ casing, lid, spigot, vane, rail, collar, bracket })) {
console.log(name, await sheetMetal.check({ part }));
}
await bitbybit.draw.drawAnyAsync({
entity: [casing, liftedLid, liftedSpigot, vane, rail, collar, bracket, otherEnd, otherSide, otherCorner],
options: bitbybit.draw.optionsOcctSheet({}),
});
bitbybit.babylon.scene.adjustActiveArcRotateCamera({ position: [-600, 700, 480], lookAt: [-10, 170, 0], minZ: 10, maxZ: 2000 });
The script runs for a while: it builds seven parts with over fifty sheet metal operations. Its sizes are millimetres, the casing 300 long, 200 wide and 150 high in 1 mm sheet, the brackets in 1.5 mm. The TypeScript tab is the easiest to read; the Rete and Blockly tabs build the same parts node by node and block by block, each picker and point as a node or block of its own.
The camera also sets its near and far planes, minZ 10 and maxZ 2000, for a box about 300 wide seen from about 900 away. The depth buffer's precision is spread between the two planes, most of it near the first, so a near plane far closer than anything drawn leaves little where the box is, and faces a millimetre apart, the two sides of the sheet, can flicker through each other. A far plane of 2000 still leaves room to orbit and zoom out.
The casing
The casing starts as a 300 by 200 plate, the floor, with cornerRelief set to circular so every later corner of the sheet is relieved the same way. Its four walls are bent up in one call to flanges, 150 high: the walls meet mitred at the corners, a tenth of a millimetre apart, the way the casing is folded from a single blank and welded along the corner seams. The edges are picked with insideEdgeToward in a fixed order, toward -x, +x, -z and +z, so the walls are named wall (the inlet end), wall.2 (the back), wall.3 and wall.4 (the long sides), and the script names them once as constants.
The long walls get a 15 mm flange turned in along their tops: a lip for the lid's screws to bite into. Each stops 6 short of the corners, clear of the mitres. The end walls get a hem instead, a closed one on the inlet end and a teardrop on the back, which stiffen the free edges and take away the cut edge a fitter's hand would meet. They too stop 6 short of the corners, where they would otherwise run into the lips, and the teardrop is given no length, so its run is as long as fits.
Then come the holes, each a cut on the face of the wall it goes through: the 180 by 100 inlet opening with six bolt holes for the duct collar round it, and two holes at each end of both long walls for the hanger brackets.
The forms do the rest:
- four
dimpleforms pressed down out of the floor, its feet; - four
extrudedHoleforms in the floor, collars drawn down round 5 mm holes for the motor's mounting screws; - two
beadforms along the floor, stiffening it against the fan's vibration; - two
bridgeforms near the back, straps for cable ties; - four
louverforms in one long wall, letting the speed controller's heat out; - an
embosson the other long wall, a raised panel that stops a large flat panel from drumming; - two
extrudedHoleforms in each lip, so the lid's screws thread into a collar rather than into 1 mm of sheet.
A lance presses a hook out of the back wall for the controller's cable, and two gusset forms lock the bend between the floor and the back wall, which carries the controller.
The lid
The lid is a plate drawn facing down at the casing's top, so its inside face is its underside and its four skirts bend down over the walls. They are bent one at a time with flange, 20 long and stopping 5 short of each corner, because their corners are to be closed by overlaps, which a fabricator spot-welds; mitred flanges would leave them open. Each of the four corners is then closed with kind set to overlap, the two skirts' end faces at that corner picked with endFaceToward by the direction each lies in: the long skirts reach over the short ones' edges, the skirts' bends are carried on into the corner, and the top's corner is cut back to clear them.
A cut takes the outlet opening and four screw holes out of the top in one call, matching the lips' collars. A second cut, with a depth of 0.4 and the face picked by outsideFace, pockets a label recess into the top. Last, a rip cuts a 6 wide slot up from the back skirt's lower edge, so the controller's cable can leave under the closed lid.
The outlet
The outlet is a square-to-round transition, a loft from the lid's 160 by 110 opening to a 125 round duct 80 higher, bent into 16 facets round the circle. side is outside, so its square end is exactly the opening's size and its round end the duct's inside size. It opens along a seam, as a transition bent from one blank does.
The turning vane
Inside, the air has to turn from the inlet's direction up into the outlet. A curved turning vane guides it: a loft with method set to formed, ruled between two identical L-shaped profiles with a 60 mm filletRadius, so the vane is one smooth formed region, rolled rather than bent, spanning the casing's width.
The DIN rail
The speed controller clips onto a standard 35 mm top-hat rail on the back wall. The rail is a contour: a six-point profile of lips, sides and top run 120 long, with side set to right so its lips lie flat against the wall, and a cut of five rounded slots in its top region, rail.3.
The duct collar
The inlet duct slides onto a collar bolted round the opening. The collar is a sweep of an L profile round the opening's rectangle: its flat leg is one web that runs round all four corners and bolts to the casing, its standing leg is mitred at each corner, and a cut puts six bolt holes in the web where the casing has them.
The hanger brackets
Each bracket starts as two plates drawn where they stand: a leg against the casing's side and an arm reaching out from its top, joined by join with one bend, named elbow. A bend with an offset of 40 jogs the arm up past the lid, so the bracket can be screwed to the ceiling while the lid still lifts off; fixed set to right keeps the leg where it is, direction set to down turns the arm upward (its inside face looks down), and position set to bendOutside starts the jog at the line. A plain bend turns the arm's end down as a stiffening lip.
A tab widens the top with an ear for a second ceiling screw, a cut puts a slot for a threaded rod and a hole in the top, a gusset stiffens the elbow, roundCorners rounds the leg's free corners, and a last cut drills the leg's two screw holes, which line up with the casing's.
Three copies come from transform: one mirrored across x = 0 for the other end of the same wall, one mirrored across z = 0 for the other wall, and the first copy mirrored again for the fourth corner. Mirrored parts are left-and-right versions, as a pair of real brackets is. Two more transform calls lift the lid and the outlet 140 so the inside shows.
Checking it
The script ends by calling check on each of the seven parts it built, then draws all ten, the seven and the three bracket copies, in their looks. Each is a sheet, with no problems and no warnings:
| Part | Regions | Bends | Made by |
|---|---|---|---|
| casing | 10 | 9 | plate, flanges, flange, hem, cut, form, lance, gusset |
| lid | 5 | 4 | plate, flange, endFaceToward, closeCorner, cut, outsideFace, rip |
| outlet | 20 | 19 | loft (bent) |
| turning vane | one formed region | 0 | loft (formed) |
| DIN rail | 5 | 4 | contour, cut |
| duct collar | 5 | 4 | sweep, cut |
| bracket | 5 | 4 | plate, join, bend, tab, cut, gusset, roundCorners, transform |
Every region and bend is named, and every face the script works on is found by a region's name, a direction or a role, so the box can be resized and still finds what it needs.
Two things the box does not do. It welds no corner shut, so it has no use for ripEdge, which opens one again along edgeBetween; joining and corners shows both. And its brackets bend at right angles with one radius, so its join is cylindrical; a conical join, one whose radius changes along the bend, is shown on the same page.
