The BIM Layer
brepjs-bim turns brepjs geometry into building information. You describe elements as typed parametric specs (a wall is a length, height, thickness, placement, and material, not a mesh); the model assembles them into a building or focused civil spatial structure, layers on property sets, materials, quantities, and classifications, and serializes the result to a valid IFC-SPF file. A matching importer reads IFC back in.
npm install brepjs-bim brepjs web-ifcTwo ways in:
- Through families (recommended for new models): author a declarative element tree with brepjs-families and project it with
familiesToBim. Identity, openings, and containment come from the tree; GlobalIds derive from key paths and survive reorders. Start at IFC Export. - Direct
BimModel: imperativeadd*calls when you already know exactly what to build, or when you need elements the families projection does not cover yet.
import { BimModel, toIfc } from 'brepjs-bim';
import { unwrap } from 'brepjs';
const model = new BimModel();
model.init({ name: 'Example' });
const siteId = unwrap(model.addSite({ name: 'Site' }));
const buildingId = unwrap(model.addBuilding({ name: 'Building' }));
const storeyId = unwrap(model.addStorey({ name: 'Level 1', elevation: 0 }));
const project = model.getProject();
if (project) model.aggregate(project.localId, siteId);
model.aggregate(siteId, buildingId);
model.aggregate(buildingId, storeyId);
const wall = model.addWall({
length: 4000,
height: 3000,
thickness: 200,
origin: [0, 0, 0],
axisX: [1, 0, 0],
axisZ: [0, 0, 1],
materialName: 'Concrete',
});
if (wall.ok) model.placeIn(wall.value, storeyId);
const ifc = await toIfc(model, { applicationName: 'example-app', applicationVersion: '1' });
// ifc.ok && ifc.value instanceof Uint8ArrayThree design decisions carry the package:
- Typed specs anchor the model. Every
add*call validates its spec (zod schemas; theparse*Specfunctions are exported for standalone use) and stores a typed element. Parametric physical specs build analytical solids, with IFC encoding determined by the element type. Civil spatial elements are body-less, while explicitly arbitrary bodies such as Earthworks Fill serialize as tessellation. Families-projected civil walls and railings always retain the evaluated authored items as anAUTHORITATIVEProduct Body and export every item as tessellation. - Geometry is unplaced template geometry. Element solids live in local coordinates;
origin/axisX/axisZare applied by the IFC layer viaIfcLocalPlacement.placedSolids(element)applies the element frame; when its spatial parent is placed, pass the cumulativeparentFrameto obtain world coordinates. - Results, not exceptions. Every operation returns
Result<T, BimError>from brepjs. Validation issues travel inside reports; nothing throws across the API boundary.
Dimensions are millimeters everywhere; IFC export emits SI metres. Reading element geometry needs only the brepjs kernel; toIfc / fromIfc additionally load the web-ifc peer dependency.
Focused civil bridge profile
For IFC4X3, the public Families path supports Project → Site → Bridge → recursively nested Bridge Part, exact Earthworks Fill bodies, and nearest-part product containment. Civil Product semantics route the infrastructure fixture's existing Beam (beam, cross-girder, girder), Column (pier-stem), Footing (pad), Railing (guardrail), Slab (deck), and Wall (wall) categories to their normal typed BIM elements. Semantic material is used when the element does not separately provide materialName.
Civil-semantic wall and railing routes require bodyEvaluator or the proxyEvaluator fallback to retain their authored Product Bodies. Without an evaluator, projection returns FAMILIES_PRODUCT_BODY_EVALUATOR_REQUIRED. Conventional archetype walls and railings retain their existing recipe authoring behavior and do not need an evaluator. The adapter registers wall openings before installing the authored Body and copies every borrowed evaluator item into Product-local coordinates. It retains AUTHORITATIVE authority even when the geometry coincides with the nominal recipe. These products keep their typed Wall or Railing classification and export every Body item as tessellation. The evaluator's source handles remain borrowed. Other typed civil routes continue to use the reference Families' semantic envelope dimensions.
Member and Sign are explicitly outside this profile. They remain hard unsupported-type errors unless proxyEvaluator is deliberately enabled, in which case projected.proxied reports them. This profile does not claim complete IFC infrastructure coverage or unchanged full scratch-example parity.
Continue with the element catalog, IFC export & import, validation, and interop.
IfcOpenShell 0.8.5 currently reports a tessellation Normals schema error for the existing IFC4X3 writer, including single Proxy and retained Families Body items. The verified fixtures still produce the expected shapes and world placement. IFC4X3 schema conformance is not established by those geometry checks.
Examples
These playground examples build BIM models and export them to IFC.
Office BuildingA steel-framed office building of seven storeys as a BIM model. Each column, beam, slab, wall, stair, door and curtain wall is a typed element in a storey, so the kernel takes off the steel and the concrete, and the Files button saves the IFC file. The steel sections, the planning grid, the storey height, the slab depth, the stair and the facade module are published figures. The core layout, the foundations and the roof are a display model.
Braced Steel FrameA 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.
Curtain WallA curtain wall on a facade that turns a corner, as a BIM model. Each facet is a stack of IfcCurtainWall grids of glass panes between mullions and transoms, on its own wall line, and placedSolids() applies the two levels of the placement. The planning module, the storey height, the mullion and the glass unit are published figures, and the kernel measures the area of the vision glass. The slabs, the brackets, the back pans and the corner post are a display model.
Datacenter HallA data hall designed on the 600 mm tile grid: four rows of 42U racks on the metric 8-tile pitch with hot-aisle containment, a fully perforated cold-aisle floor over a raised-floor plenum, six CRAH units sized N+1, and A+B power down redundant 250 A overhead busway. Each element carries datacenter psets (with the IFC class that a native writer would use) and is in a zone or a system. The console runs the capacity checks of a design review, and the Files button saves the equipment schedule. The view lifts the floor at one end to show the plenum. The rack fronts, the supports, the cables and the pipes are a display model.