Skip to content

Braced Steel Frame ​

Braced Steel Frame, rendered in the brepjs playground
BIM · 216 lines▶ Run it in the playground

A braced steel frame of two storeys as a BIM model: columns on a grid, a beam grid at each floor, tube bracing with gusset plates, a slab on each level and a base under each column, all grouped as one IfcElementAssembly. The sections, the grid, the storey height, the slab depth and the column base are published figures, and the kernel measures the mass of the steel against the section tables. The view shows each M24 holding down bolt as a screw with a helical thread in its nut, and the IFC file keeps it as a plain proxy. The layout of the bracing, the gussets and the footings are a display model.

Code ​

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

ts
import { BimModel, placedSolids, toIfc } from 'brepjs-bim';
import { box, clone, compound, cutAll, cylinder, extrude, fuseAll, getSolids, line, loft, measureVolume, polygon, translate, unwrap, wire } from 'brepjs/quick';
import { color, present } from 'brepjs/playground';

// Braced steel frame as a BIM model: columns on a grid, a beam grid at each floor, tube bracing, a slab on each
// level and a base under each column, all members of one IfcElementAssembly. The sections, the grid, the storey
// height, the slab depth and the column base are published figures. The layout of the bracing, the gussets and
// the footings are a display model. Units are millimetres. Z is up and the origin is at one corner column.
interface FrameParams {
  storeys?: number; // 1 to 3
  bays?: number; // bays of 6 m along X
  deck?: number; // part of each slab to show, 0 to 1. The IFC file keeps the whole slabs
}

// ---- published figures
// Rolled sections: depth, width, web, flange, root radius, and the table mass in kg for each metre.
const HE240B = { h: 240, b: 240, tw: 10, tf: 17, r: 21, kg: 83.2 };
const IPE400 = { h: 400, b: 180, tw: 8.6, tf: 13.5, r: 21, kg: 66.3 };
const IPE300 = { h: 300, b: 150, tw: 7.1, tf: 10.7, r: 15, kg: 42.2 };
const SHS = { b: 150, t: 6.3, ro: 9.45, ri: 6.3, kg: 28.1 }; // hot finished square tube for the bracing
const STEEL = 7850e-9; // kg in each mm3
const GRID = { x: 6000, y: 9000, storey: 3600 }; // a usual grid of 6 m by 9 m
const SLAB = 150; // composite slab
// Column base: a plate 100 mm larger than the column all round, four M24 bolts, 25 to 50 mm of grout.
const BASE = { plate: 450, thickness: 25, grout: 30, bolt: 24, minor: 20.752, pitch: 3, nut: 21.5, flats: 36, washer: 44, washerHole: 25, washerT: 4 }; // M24: metric coarse thread, right hand

// ---- display model
const SECONDARY = 3000; // spacing of the floor beams
const EDGE = 200; // the slab goes past the grid lines
const GUSSET = { plate: 15, reach: 520, half: 110 };
const FOOTING = { size: 1500, depth: 600 };
const ANCHOR = { embed: 300, hole: 30, play: 0.15 }; // a holding down bolt in the footing, its hole in the plate, the play of its nut
const COLORS = { column: '#c3c9d1', beam: '#12b5b0', brace: '#ff5a1f', plate: '#8a99ad', bolt: '#d3a956', slab: '#cfcabb', base: '#a8a294' };
type Tone = keyof typeof COLORS;
type P3 = [number, number, number];
type Body = ReturnType<typeof box>;
type Id = Extract<ReturnType<BimModel['addBeam']>, { ok: true }>['value']; // the id of an element in the model
type Section = { h: number; b: number; tw: number; tf: number; r: number };
const X: P3 = [1, 0, 0], Y: P3 = [0, 1, 0], Z: P3 = [0, 0, 1];
const rolled = (s: Section) => ({ kind: 'I_BEAM', overallWidth: s.b, overallDepth: s.h, flangeThickness: s.tf, webThickness: s.tw, filletRadius: s.r }) as const;

function frame({ storeys = 2, bays = 2, deck = 0.5 }: FrameParams = {}) {
  const model = new BimModel(), owned: { delete(): void }[] = [];
  const own = <T extends { delete(): void }>(s: T): T => { owned.push(s); return s; };
  try {
    model.init({ name: 'Steel frame' });
    const site = unwrap(model.addSite({ name: 'Site' }));
    const building = unwrap(model.addBuilding({ name: 'Building' }));
    const storey = unwrap(model.addStorey({ name: 'Ground floor', elevation: 0 }));
    const project = model.getProject();
    if (project) model.aggregate(project.localId, site);
    model.aggregate(site, building);
    model.aggregate(building, storey);
    const tones = new Map<Id, Tone>();
    let tableKg = 0;
    const put = (tone: Tone, made: ReturnType<BimModel['addBeam']>, kg = 0): Id => {
      const id = unwrap(made);
      model.placeIn(id, storey);
      tones.set(id, tone);
      tableKg += kg;
      return id;
    };
    const steel = { materialName: 'Steel S355' };
    const levels = Math.min(Math.max(Math.round(storeys), 1), 3), nx = Math.min(Math.max(Math.round(bays), 1), 3);
    const lines = Array.from({ length: nx + 1 }, (_, i) => i * GRID.x), rows = [0, GRID.y];
    const tops = Array.from({ length: levels }, (_, i) => (i + 1) * GRID.storey - SLAB); // top of steel of each level

    // Columns on the grid, from the base to the roof steel. Their flanges face along Y.
    const height = tops[levels - 1]!;
    for (const x of lines) for (const y of rows)
      put('column', model.addColumn({ height, profile: rolled(HE240B), origin: [x, y, 0], axisX: X, axisZ: Z, ...steel }), height / 1000 * HE240B.kg);
    const slabs: Id[] = [];
    for (const top of tops) {
      // Primary beams across the frame, between the column flanges.
      const span = GRID.y - HE240B.h;
      for (const x of lines)
        put('beam', model.addBeam({ length: span, profile: rolled(IPE400), origin: [x, HE240B.h / 2, top - IPE400.h / 2], axisX: Y, axisZ: Z, ...steel }), span / 1000 * IPE400.kg);
      // Floor beams along the frame at 3 m. On a grid line they go to the column webs, and between the grid lines
      // they stop at the flanges of the primary beams.
      for (let y = 0; y <= GRID.y; y += SECONDARY) for (let i = 0; i < nx; i++) {
        const gap = y === 0 || y === GRID.y ? HE240B.tw / 2 : IPE400.b / 2;
        put('beam', model.addBeam({ length: GRID.x - 2 * gap, profile: rolled(IPE300), origin: [i * GRID.x + gap, y, top - IPE300.h / 2], axisX: X, axisZ: Z, ...steel }), (GRID.x - 2 * gap) / 1000 * IPE300.kg);
      }
      // The slab on the beams. An opening lets each column go through the floor slabs.
      const slab = put('slab', model.addSlab({ length: nx * GRID.x + 2 * EDGE, width: GRID.y + 2 * EDGE, thickness: SLAB, origin: [-EDGE, -EDGE, top], axisX: X, axisZ: Z, predefinedType: top === height ? 'ROOF' : 'FLOOR', materialName: 'Concrete C30/37' }));
      slabs.push(slab);
      if (top < height) for (const x of lines) for (const y of rows)
        unwrap(model.addSlabOpening({ slabLocalId: slab, offsetX: x + EDGE - HE240B.b / 2, offsetY: y + EDGE - HE240B.h / 2, sizeX: HE240B.b, sizeY: HE240B.h }));
    }

    const kit = { model, put, own, levels, nx, tops };
    bracing(kit);
    const anchor = bases(kit, lines, rows);

    // One assembly holds the frame: the IFC file groups all the parts under it.
    const assembly = unwrap(model.addElementAssembly({ name: 'Frame', predefinedType: 'BRACED_FRAME' }));
    for (const id of tones.keys()) model.aggregate(assembly, id);

    // The view and the takeoff. placedSolids() gives each element in its place. The kernel measures each steel
    // member, and a density gives its mass. The view cuts the slabs back to show the beams. It also shows each holding
    // down bolt whole, in its holes, in the place of the proxy that the IFC file keeps.
    const groups: Record<Tone, Body[]> = { column: [], beam: [], brace: [], plate: [], bolt: [], slab: [], base: [] };
    const share = Math.min(Math.max(deck, 0), 1), length = nx * GRID.x + 2 * EDGE;
    const open = own(box(length, GRID.y + 2 * EDGE + 2, 2 * height, { at: [-EDGE + share * length + length / 2, GRID.y / 2, height] }));
    let kg = 0;
    for (const el of model.getAllElements()) {
      const tone = tones.get(el.localId);
      if (!tone) continue;
      const placed = unwrap(placedSolids(el)).map((body) => own(body));
      if (tone === 'column' || tone === 'beam' || tone === 'brace') kg += placed.reduce((sum, body) => sum + unwrap(measureVolume(body)), 0) * STEEL;
      if (slabs.includes(el.localId)) {
        if (share <= 0) continue;
        groups.slab.push(...(share < 1 ? placed.map((body) => own(unwrap(cutAll(body, [open])))) : placed));
      } else if (tone !== 'bolt') {
        const drills = anchor.holes.get(el.localId);
        groups[tone].push(...(drills ? placed.map((body) => own(unwrap(cutAll(body, drills)))) : placed));
      }
    }
    groups.bolt = anchor.screws.map((at) => own(translate(anchor.screw, at)) as Body);
    const shown = (Object.keys(COLORS) as Tone[]).filter((tone) => groups[tone].length > 0).map((tone) => color(compound(groups[tone]), COLORS[tone]));
    return { model, shown, kg, tableKg, members: [...tones.values()].filter((tone) => tone === 'column' || tone === 'beam' || tone === 'brace').length };
  } catch (error) {
    model[Symbol.dispose]();
    throw error;
  } finally {
    owned.splice(0).forEach((body) => body.delete());
  }
}

type Kit = { model: BimModel; put: (tone: Tone, made: ReturnType<BimModel['addBeam']>, kg?: number) => Id; own: <T extends { delete(): void }>(s: T) => T; levels: number; nx: number; tops: number[] };

// Bracing: two tubes in each braced bay go from the column feet to the middle of the beam over them. A gusset
// plate at each end joins the tube to the frame. Both end frames and one bay of each side are braced.
function bracing({ model, put, own, levels, nx, tops }: Kit): void {
  const tube = { kind: 'RECTANGLE_HOLLOW', xDim: SHS.b, yDim: SHS.b, wallThickness: SHS.t, outerFilletRadius: SHS.ro, innerFilletRadius: SHS.ri } as const;
  // A braced bay is a plane: o is the foot of its first column face, h its direction, and it is wide and high.
  const bay = (o: P3, h: P3, wide: number, high: number): void => {
    const at = (s: number, z: number): P3 => [o[0] + s * h[0], o[1] + s * h[1], o[2] + z];
    const normal: P3 = [-h[1], h[0], 0], t = GUSSET.plate;
    const plate = (points: [number, number][]): void => {
      const face = own(unwrap(polygon(points.map(([s, z]): P3 => { const p = at(s, z); return [p[0] - normal[0] * t / 2, p[1] - normal[1] * t / 2, p[2]]; }))));
      put('plate', model.addProxy({ name: 'Gusset plate', solid: unwrap(extrude(face, [normal[0] * t, normal[1] * t, 0])) as Body, materialName: 'Steel S355' }));
    };
    const angle = Math.atan2(high, wide / 2), c = Math.cos(angle), s = Math.sin(angle), r = GUSSET.reach, w = GUSSET.half;
    // The plate under the beam takes both tubes.
    const reachX = r * c + w * s + 20;
    plate([[wide / 2 + reachX, high], [wide / 2 + r * c + w * s, high - r * s + w * c], [wide / 2 + r * c - w * s, high - r * s - w * c], [wide / 2 - r * c + w * s, high - r * s - w * c], [wide / 2 - r * c - w * s, high - r * s + w * c], [wide / 2 - reachX, high]]);
    for (const side of [1, -1]) {
      // A plate in the corner at the column foot, then the tube from plate to plate.
      const foot = (ds: number): number => (side > 0 ? ds : wide - ds);
      plate([[foot(0), 0], [foot(r * c + w * s + 20), 0], [foot(r * c + w * s), r * s - w * c], [foot(r * c - w * s), r * s + w * c], [foot(0), r * s + w * c + 20]]);
      const from = at(foot(r * c), r * s), to = at(wide / 2 - side * r * c, high - r * s);
      const length = Math.hypot(to[0] - from[0], to[1] - from[1], to[2] - from[2]);
      const axisX: P3 = [(to[0] - from[0]) / length, (to[1] - from[1]) / length, (to[2] - from[2]) / length];
      const axisZ: P3 = [normal[1] * axisX[2] - normal[2] * axisX[1], normal[2] * axisX[0] - normal[0] * axisX[2], normal[0] * axisX[1] - normal[1] * axisX[0]];
      put('brace', model.addBeam({ length, profile: tube, origin: from, axisX, axisZ, materialName: 'Steel S355' }), length / 1000 * SHS.kg);
    }
  };
  for (let level = 0; level < levels; level++) {
    const floor = level === 0 ? 0 : tops[level - 1]! + SLAB, top = tops[level]!;
    for (const x of [0, nx * GRID.x]) bay([x, HE240B.h / 2, floor], Y, GRID.y - HE240B.h, top - IPE400.h - floor);
    bay([HE240B.tw / 2, 0, floor], X, GRID.x - HE240B.tw, top - IPE300.h - floor);
    bay([(nx - 1) * GRID.x + HE240B.tw / 2, GRID.y, floor], X, GRID.x - HE240B.tw, top - IPE300.h - floor);
  }
}

// A base under each column: a pad footing, a bed of grout, a base plate and four holding down bolts.
function bases({ model, put, own }: Kit, lines: number[], rows: number[]) {
  const one = (shape: Parameters<typeof getSolids>[0]): Body => unwrap(clone(getSolids(own(shape))[0]!)) as Body;
  const hex = own(unwrap(polygon(Array.from({ length: 6 }, (_, i): P3 => [BASE.flats / Math.sqrt(3) * Math.cos(i * Math.PI / 3), BASE.flats / Math.sqrt(3) * Math.sin(i * Math.PI / 3), BASE.washerT]))));
  // The part of a bolt over the plate: washer, nut and the end of the thread.
  const bolt = own(one(unwrap(fuseAll([own(cylinder(BASE.washer / 2, BASE.washerT)), own(unwrap(extrude(hex, BASE.nut))), own(cylinder(BASE.bolt / 2, BASE.washerT + BASE.nut + 20))]))));
  const p = BASE.plate, under = -BASE.thickness - BASE.grout, hold = p / 2 - 55;
  // The view shows the whole bolt as a real screw: a plain shank from the footing up through the grout and the plate,
  // then a core with one helical tooth, a washer, and a nut with the mating tooth, half a pitch out of phase.
  const tooth = (core: number, tip: number, from: number, to: number, ref: number): Body => {
    const root = tip > core ? core / 0.998 : core * 0.998, half = 0.42 * BASE.pitch; // a hair clear of the core or the bore
    const start = from + half, span = to - from - 2 * half, pieces = Math.ceil(span / (4 * BASE.pitch));
    const n = Math.round(span / pieces / BASE.pitch * 24); // 24 loft sections in each turn
    const section = (z: number) => {
      const a = 2 * Math.PI * (z - ref) / BASE.pitch;
      const pts = [[root, -half], [tip, 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]!))))));
    };
    // A row of lofts of 4 turns or less, end to end on one helix: a long loft is slow to mesh.
    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 Body;
  };
  const drilled = (body: Body, r: number, z: number, depth: number): Body => own(unwrap(cutAll(body, [own(cylinder(r, depth + 2, { at: [0, 0, z - 1] }))]))) as Body;
  const low = under - ANCHOR.embed, top = BASE.washerT + BASE.nut + 20, bore = BASE.bolt / 2 + ANCHOR.play;
  const screw = own(compound([
    own(cylinder(BASE.bolt / 2, -low, { at: [0, 0, low] })), own(cylinder(BASE.minor / 2, top)), tooth(BASE.minor / 2, BASE.bolt / 2, 0, top, 0),
    drilled(own(cylinder(BASE.washer / 2, BASE.washerT)), BASE.washerHole / 2, 0, BASE.washerT),
    drilled(own(unwrap(extrude(hex, BASE.nut))) as Body, bore, BASE.washerT, BASE.nut), tooth(bore, BASE.minor / 2 + ANCHOR.play, BASE.washerT, BASE.washerT + BASE.nut, BASE.pitch / 2),
  ])) as Body;
  const screws: P3[] = [], holes = new Map<Id, Body[]>(); // where the bolts are, and the holes that the view drills for them
  for (const x of lines) for (const y of rows) {
    const spots = [-hold, hold].flatMap((dx) => [-hold, hold].map((dy): P3 => [x + dx, y + dy, 0]));
    const drill = (r: number, z0: number, z1: number): Body[] => spots.map(([sx, sy]) => own(cylinder(r, z1 - z0, { at: [sx, sy, z0] })));
    screws.push(...spots);
    holes.set(put('base', model.addFooting({ length: FOOTING.size, width: FOOTING.size, thickness: FOOTING.depth, origin: [x - FOOTING.size / 2, y - FOOTING.size / 2, under - FOOTING.depth], axisX: X, axisZ: Z, predefinedType: 'PAD_FOOTING', materialName: 'Concrete C30/37' })), drill(BASE.bolt / 2, low, under + 1));
    holes.set(put('base', model.addProxy({ name: 'Grout', solid: box(p + 60, p + 60, BASE.grout, { at: [x, y, under + BASE.grout / 2] }), materialName: 'Grout' })), drill(BASE.bolt / 2 + 0.2, under - 1, -BASE.thickness + 1));
    holes.set(put('plate', model.addProxy({ name: 'Base plate', solid: box(p, p, BASE.thickness, { at: [x, y, -BASE.thickness / 2] }), materialName: 'Steel S355' })), drill(ANCHOR.hole / 2, -BASE.thickness - 1, 1));
    for (const at of spots) put('bolt', model.addProxy({ name: 'Holding down bolt M24', solid: translate(bolt, at), materialName: 'Steel 8.8' }));
  }
  return { screw, screws, holes };
}

// Try frame({ storeys: 3 }), frame({ bays: 3 }) or frame({ deck: 0 }).
const scene = frame();
console.log(scene.members + ' steel members: the kernel measures ' + (scene.kg / 1000).toFixed(2) + ' t, the section tables give ' + (scene.tableKg / 1000).toFixed(2) + ' t.');
// The tree panel shows the IFC structure. The IFC button saves the model as a file.
export default present(scene.shown, {
  bimTree: scene.model.toTreeSummary(),
  ifc: async () => unwrap(await toIfc(scene.model, { applicationName: 'brepjs playground', applicationVersion: '1.0' })),
});

Functions used ​

placedSolids toIfc box clone compound cutAll cylinder extrude fuseAll getSolids line loft measureVolume polygon translate unwrap wire color present

▶ Run Braced Steel Frame in the playground

Released under the Apache 2.0 License.