Skip to content

Slotted Strut Channel ​

Slotted Strut Channel, rendered in the brepjs playground
Sheet Metal · 173 lines▶ Run it in the playground

A slotted strut channel, folded from one strip with six bends, as a trapeze hanger: two threaded rods carry it and two U-bolts hold a pipe each. The 41 mm section, the 2.5 mm gauge, the 14 x 28 mm slots at 50 mm, the mass for each metre and the M10 and M8 threads are published figures. The rods and the legs of the U-bolts have true helical threads, and each nut has the mating thread. The kernel unfolds the section to the flat strip and measures the mass. The lips, the pipes and the hardware are a display model. The DXF button downloads the flat strip.

Code ​

This is the full program. The playground runs it in your browser without a change.

ts
import { box, circle, clone, compound, cut, cylinder, extrude, face, line, loft, measureVolume, polygon, revolve, rotate, translate, unwrap, wire } from 'brepjs/quick';
import { addPolygonCutout, author, flatPatternToPolylines, toDXF, unfold } from 'brepjs-sheetmetal';
import { color, present } from 'brepjs/playground';

// Slotted strut channel, 41 x 41 mm, as a trapeze hanger: two threaded rods carry it, and two U-bolts hold a pipe each.
// One strip of steel makes the section: a back, two walls, and two lips that turn in and down. That is six bends.
// The section size, the gauge, the slots, the mass and the threads are published figures. The lips, the pipes and the hardware are a display model.
interface ChannelParams {
  fold?: number; // 0 to 1: how far each bend is folded. Below 1 the example shows only the strip
  length?: number; // millimetres, a multiple of the slot pitch
}

type P2 = [number, number];
type P3 = [number, number, number];
type Shape = ReturnType<typeof box>;
type Part = Extract<ReturnType<typeof author>, { ok: true }>['value'];

// Kernel shapes live in WASM memory. Every temporary goes through own(). freeing() runs a build and then frees them all.
const owned: { delete(): void }[] = [];
const own = <T extends { delete(): void }>(s: T): T => {
  owned.push(s);
  return s;
};
const freeing = <T,>(build: () => T): T => { try { return build(); } finally { owned.splice(0).forEach((s) => s.delete()); } }; // also when the build throws

// ---- published figures (strut channel 41 x 41 x 2.5, slotted)
const SIZE = 41; // width and height of the section
const T = 2.5; // sheet thickness
const SLOT = { width: 14, length: 28, pitch: 50 };
const CATALOGUE = { plain: 2.61, slotted: 2.4 }; // kilograms per metre
const STEEL = 7.85e-6; // kilograms per cubic millimetre
const M10 = { d: 10, minor: 8.376, pitch: 1.5 }; // metric coarse thread, right hand: the rods
const M8 = { d: 8, minor: 6.647, pitch: 1.25 }; // the U-bolts

// ---- display model
const RULE = { innerRadius: 1.25, kFactor: 0.44 }; // a tight roll-formed corner
const S = T + RULE.innerRadius; // a 90 degree bend takes this much of each leg
const OPENING = 22; // between the lips
const RETURN = 9.5; // how far each lip turns down
const ROD = { radius: 5, height: 120, nut: 16, nutHeight: 8.4 }; // M10 threaded rod
const PIPE = { radius: 21.2, wall: 3.2, length: 200 };
const UBOLT = { radius: 4, nut: 13, nutHeight: 6.5, thread: 26 }; // M8, with this length of thread on each leg
const PLAY = 0.08; // radial play between a thread and its nut

const made = (r: ReturnType<typeof author>): Part => {
  const p = unwrap(r);
  if (p.solid) own(p.solid);
  return p;
};
// An obround slot along X, as a polygon.
const slot = (x: number, y: number, length: number, width: number): P2[] => {
  const r = width / 2, d = length / 2 - r, n = 8;
  const end = (cx: number, from: number): P2[] => Array.from({ length: n + 1 }, (_, i): P2 => [cx + r * Math.cos(from + (i * Math.PI) / n), y + r * Math.sin(from + (i * Math.PI) / n)]);
  return [...end(x + d, -Math.PI / 2), ...end(x - d, Math.PI / 2)];
};
const lathe = (pts: P2[]): Shape => own(unwrap(revolve(own(unwrap(polygon(pts.map(([r, z]): P3 => [r, 0, z])))))) as Shape);
const at = (s: Shape, x: number, y: number, z: number): Shape => own(translate(s, [x, y, z]) as Shape);
// A hex nut with its hole, flat on Z = 0.
const hexNut = (across: number, height: number, bore: number): Shape => {
  const r = across / Math.sqrt(3);
  const hex = own(unwrap(extrude(own(unwrap(polygon(Array.from({ length: 6 }, (_, i): P3 => [r * Math.cos((i * Math.PI) / 3), r * Math.sin((i * Math.PI) / 3), 0])))), height)));
  return own(unwrap(cut(hex, own(cylinder(bore, height)))) as Shape);
};

// One helical thread tooth about +Z, with its crest from z = from to z = to. Its crest passes the +X side at z = ref.
// The tooth is a row of smooth lofts of 4 turns or less, end to end on one helix: a long loft is slow to mesh.
// tip > core is the thread of a screw on a core of that radius. tip < core is the thread in a bore.
const SECTIONS = 12; // loft sections in each turn
const SLACK = 0.998; // keeps the tooth a hair clear of its core or its bore
const helixTooth = (core: number, tip: number, pitch: number, from: number, to: number, ref: number): Shape => {
  const root = tip > core ? core / SLACK : core * SLACK;
  const crest = tip > core ? tip : tip / SLACK;
  const half = 0.42 * pitch;
  const start = from, span = to - from, pieces = Math.ceil(span / (4 * pitch));
  const n = Math.max(2, Math.round((span / pieces / pitch) * SECTIONS)); // sections in each piece
  const section = (z: number) => {
    const a = (2 * Math.PI * (z - ref)) / pitch;
    const pts = [[root, -half], [crest, 0], [root, half]].map(([r, dz]): P3 => [r! * Math.cos(a), r! * Math.sin(a), z + dz!]);
    return own(unwrap(wire(pts.map((q, i) => own(line(q, pts[(i + 1) % 3]!))))));
  };
  const lofts = Array.from({ length: pieces }, (_, k) => own(unwrap(loft(Array.from({ length: n + 1 }, (_, j) => section(start + (span * (k + j / n)) / pieces)), { ruled: false }))));
  return own(compound(lofts)) as Shape;
};
// The thread of a screw between two heights, and the mating thread of a nut or a tapped hole, half a pitch out of phase.
type Thread = { d: number; minor: number; pitch: number };
const screwTooth = (m: Thread, z0: number, z1: number): Shape => helixTooth(m.minor / 2, m.d / 2, m.pitch, z0 + m.pitch / 2, z1 - m.pitch / 2, 0);
const nutTooth = (m: Thread, z0: number, z1: number): Shape => helixTooth(m.d / 2 + PLAY, m.minor / 2 + PLAY, m.pitch, z0 + m.pitch / 2, z1 - m.pitch / 2, m.pitch / 2);

// The strip: the back with its slots, two walls, two lips and two returns.
function strip(length: number, angle: number): Part {
  const bend = { angleDeg: angle, rule: RULE };
  const flat = SIZE - 2 * S;
  const lip = (SIZE - OPENING) / 2 - 2 * S;
  let p = made(author({ thickness: T, base: { length, width: flat }, flanges: [
    { id: 'left', side: 'ymin', length: flat, ...bend }, { id: 'right', side: 'ymax', length: flat, ...bend },
    { id: 'lipLeft', parent: 'left', side: 'ymax', length: lip, ...bend }, { id: 'lipRight', parent: 'right', side: 'ymax', length: lip, ...bend },
    { id: 'returnLeft', parent: 'lipLeft', side: 'ymax', length: RETURN - S, ...bend }, { id: 'returnRight', parent: 'lipRight', side: 'ymax', length: RETURN - S, ...bend },
  ] }));
  for (let x = SLOT.pitch / 2; x < length; x += SLOT.pitch) p = made(addPolygonCutout(p, 'base', slot(x, flat / 2, SLOT.length, SLOT.width)));
  return p;
}

function channel({ fold = 1, length = 400 }: ChannelParams = {}) {
  const angle = 90 * Math.min(1, Math.max(0.02, fold));
  const part = strip(length, angle);
  // The report and the flat strip come from the full section, also when the view is part folded.
  const full = fold < 1 ? strip(length, 90) : part;
  const flat = unwrap(unfold(full));
  [flat.pattern.outline, ...flat.pattern.holes, ...flat.pattern.bendLines.map((l) => l.line)].forEach((handle) => own(handle));
  const info = {
    dxf: unwrap(toDXF(flat.pattern)), overlay2d: flatPatternToPolylines(flat.pattern),
    blank: flat.report.totalFlatSize, allowance: flat.report.bends[0]?.allowance ?? 0, bends: flat.report.bends.length,
    perMetre: (unwrap(measureVolume(full.solid as Shape)) * STEEL * 1000) / length,
  };
  // The section is centred on Y. Part folded, it lies on its back. Complete, its back is on top and its opening is down.
  const centred = own(translate(part.solid as Shape, [0, -(SIZE - 2 * S) / 2, 0]) as Shape);
  if (fold < 1) return { steel: unwrap(clone(centred)) as Shape, ...info };
  const steel = rotate(centred, 180, { axis: [1, 0, 0], at: [0, 0, SIZE / 2] }) as Shape;

  const zinc: Shape[] = [], pipes: Shape[] = [];
  const slots = Array.from({ length: Math.floor(length / SLOT.pitch) }, (_, i) => SLOT.pitch / 2 + i * SLOT.pitch);
  const inside = SIZE - T; // the under side of the back
  // Two threaded rods through the end slots. A washer and a nut on each side of the back clamp the channel.
  const washer = (outer: number, inner: number): Shape => lathe([[inner, 0], [outer, 0], [outer, 2], [inner, 2]]);
  // Each rod has one helical tooth on its full length, 80 turns. The nuts have the mating tooth.
  const rodNut = hexNut(ROD.nut, ROD.nutHeight, M10.d / 2 + PLAY), rodWasher = washer(11, 5.25);
  const rodEnd = inside - 22, upper = SIZE + 2, lower = inside - 2 - ROD.nutHeight; // the low end of a rod and of its two nuts
  const rodThread = [screwTooth(M10, rodEnd, rodEnd + ROD.height)];
  const rod = own(compound([own(cylinder(M10.minor / 2, ROD.height, { at: [0, 0, rodEnd] })), ...rodThread, ...[upper, lower].map((z) => nutTooth(M10, z, z + ROD.nutHeight))]) as Shape);
  for (const x of [slots[0]!, slots[slots.length - 1]!]) {
    zinc.push(at(rod, x, 0, 0));
    zinc.push(at(rodWasher, x, 0, SIZE), at(rodNut, x, 0, upper), at(rodWasher, x, 0, inside - 2), at(rodNut, x, 0, lower));
  }
  // A pipe lies on the back between two slots. The legs of its U-bolt go through the slots to a nut each.
  const reach = PIPE.radius + UBOLT.radius;
  const tube = own(rotate(lathe([[PIPE.radius - PIPE.wall, 0], [PIPE.radius, 0], [PIPE.radius, PIPE.length], [PIPE.radius - PIPE.wall, PIPE.length]]), 90, { axis: [1, 0, 0] }) as Shape);
  const round = own(unwrap(face(own(unwrap(wire([own(circle(UBOLT.radius, { at: [reach, 0, 0] }))]))) as never)));
  const arch = own(unwrap(revolve(round, { axis: [0, 1, 0], angle: -Math.PI })) as Shape);
  const boltNut = hexNut(UBOLT.nut, UBOLT.nutHeight, M8.d / 2 + PLAY), boltWasher = washer(8, 4.2);
  // The end of each leg has a helical thread, and its nut has the mating tooth.
  const legEnd = inside - 14, legTop = legEnd + UBOLT.thread, nutEnd = inside - 2 - UBOLT.nutHeight;
  const legThread = own(compound([own(cylinder(M8.minor / 2, UBOLT.thread, { at: [0, 0, legEnd] })), screwTooth(M8, legEnd, legTop), nutTooth(M8, nutEnd, nutEnd + UBOLT.nutHeight)]) as Shape);
  const pairs = slots.length >= 6 ? [1, slots.length - 3] : [];
  pairs.forEach((first, n) => {
    const x = (slots[first]! + slots[first + 1]!) / 2, z = SIZE + PIPE.radius;
    pipes[n] = translate(tube, [x, PIPE.length / 2, z]) as Shape;
    zinc.push(at(arch, x, 0, z));
    for (const side of [-1, 1]) {
      zinc.push(own(cylinder(UBOLT.radius, z - legTop, { at: [x + side * reach, 0, legTop] })), at(legThread, x + side * reach, 0, 0));
      zinc.push(at(boltWasher, x + side * reach, 0, inside - 2), at(boltNut, x + side * reach, 0, nutEnd));
    }
  });
  return { steel, zinc: compound(zinc) as Shape, pipes, ...info };
}

// Try channel({ fold: 0.5 }) to see the strip half folded, or channel({ length: 600 }).
const model = freeing(() => channel());
console.log(
  model.bends + ' bends, each with an allowance of ' + model.allowance.toFixed(2) + ' mm. Flat strip: ' + model.blank.map((v) => v.toFixed(1)).join(' x ') + ' mm. ' +
    'Mass: ' + model.perMetre.toFixed(2) + ' kg/m from the kernel volume. The catalogue has ' + CATALOGUE.slotted + ' kg/m slotted and ' + CATALOGUE.plain + ' kg/m plain.',
);

// Turn the hanger so that the pipes point toward the camera.
const show = (s: Shape, css: string) => {
  const turned = rotate(s, 90, { axis: [0, 0, 1] });
  s.delete();
  return color(turned, css);
};
// The DXF button downloads the flat strip with its bend lines and slots.
export default present(
  [show(model.steel, '#c3c9d1'), ...('zinc' in model ? [show(model.zinc, '#e9ebee'), ...model.pipes.map((s, i) => show(s, i ? '#ff5a1f' : '#12b5b0'))] : [])],
  { dxf: model.dxf, overlay2d: model.overlay2d },
);

Functions used ​

box circle clone compound cut cylinder extrude face line loft measureVolume polygon revolve rotate translate unwrap wire addPolygonCutout author flatPatternToPolylines toDXF unfold color present

▶ Run Slotted Strut Channel in the playground

Released under the Apache 2.0 License.