-
Notifications
You must be signed in to change notification settings - Fork 1
core
Maarten Vroegindeweij edited this page Feb 18, 2026
·
1 revision
Layer 3 — The main library. Depends on schema, step-parser, and step-serializer. Provides IfcModel, entity management, spatial structure, property sets, documents, libraries, classifications, annotations, Dutch compliance, and query builder.
This is the package most users will interact with.
pnpm add @ifc-factory/core @ifc-factory/schemaThe central class for working with IFC data.
import { IfcModel } from '@ifc-factory/core';
// Create an empty model
const model = new IfcModel();
// Parse from STEP string
const model = IfcModel.fromStep(stepSource);
// Serialize to STEP
const output = model.toStep();// GET — Retrieve entity by expressID
const entity = model.get(42);
// Returns IfcGenericEntity | undefined
// CREATE — Create a new entity with auto-assigned ID
const wall = model.create('IfcWall', {
GlobalId: generateIfcGuid(),
Name: 'My Wall',
PredefinedType: 'SOLIDWALL',
});
console.log(wall.expressID); // auto-assigned
// UPDATE — Modify entity attributes
model.update(wall.expressID, {
Name: 'Updated Wall Name',
Description: 'Load-bearing exterior wall',
});
// DELETE — Remove an entity
model.delete(wall.expressID);
// GET ALL OF TYPE — Find all entities of a specific type
const walls = model.getAllOfType('IfcWall');
const doors = model.getAllOfType('IfcDoor');
const allRelAggregates = model.getAllOfType('IfcRelAggregates');// The IfcProject entity (first one found)
const project = model.project;
// Returns IfcGenericEntity | undefined
// Total number of entities
const count = model.size;
// Returns number
// Schema identifier
const schema = model.schema;
// Returns string (e.g., 'IFC4X3')// Get the full spatial tree
const tree = model.getSpatialTree();
// Returns SpatialTreeNode { entity, children[] }
// Get children via IfcRelAggregates
const children = model.getAggregateChildren(buildingId);
// Returns IfcGenericEntity[]
// Get elements contained in a spatial element
const elements = model.getContainedElements(storeyId);
// Returns IfcGenericEntity[]
// Place an element in a spatial structure
model.containInSpatialStructure(storeyId, wallId);
// Creates IfcRelContainedInSpatialStructureimport { createSpatialStructure } from '@ifc-factory/core';
const { project, site, building, storeys } = createSpatialStructure(model, {
projectName: 'Residential Complex',
siteName: 'Amsterdam Centrum',
buildingName: 'Block A',
storeyNames: ['Basement', 'Ground Floor', 'Floor 1', 'Floor 2', 'Roof'],
});
// Returns:
// project — IfcProject entity
// site — IfcSite entity
// building — IfcBuilding entity
// storeys — IfcBuildingStorey[] (one per name)
// All entities are connected via IfcRelAggregates:
// Project → Site → Building → Storeysimport { flattenSpatialTree } from '@ifc-factory/core';
const tree = model.getSpatialTree();
const allNodes = flattenSpatialTree(tree);
for (const node of allNodes) {
const indent = getDepth(node) * 2;
console.log(' '.repeat(indent) + `${node.entity.type}: ${node.entity.Name}`);
}interface SpatialTreeNode {
entity: IfcGenericEntity; // The spatial element
children: SpatialTreeNode[]; // Child spatial elements + contained elements
}import { createPropertySet, assignPropertySet } from '@ifc-factory/core';
const pset = createPropertySet(model, 'Pset_WallCommon', [
{ name: 'IsExternal', value: true },
{ name: 'LoadBearing', value: true },
{ name: 'FireRating', value: 'REI90' },
{ name: 'ThermalTransmittance', value: 0.18, type: 'IFCREAL' },
{ name: 'AcousticRating', value: '52 dB' },
{ name: 'Combustible', value: false },
{ name: 'SurfaceSpreadOfFlame', value: 'Class 0' },
]);
// Assign to one or more elements
assignPropertySet(model, pset.expressID, [wall1Id, wall2Id, wall3Id]);interface PropertyValue {
name: string; // Property name
value: string | number | boolean; // Property value
type?: string; // Optional IFC type hint
}Supported type values:
-
'IFCREAL'— real number -
'IFCINTEGER'— integer -
'IFCBOOLEAN'— boolean -
'IFCLABEL'— text label -
'IFCTEXT'— long text -
'IFCIDENTIFIER'— identifier string - If omitted, the type is inferred from the value's JavaScript type
import { getPropertySets } from '@ifc-factory/core';
const psets = getPropertySets(model, wallId);
for (const pset of psets) {
console.log(`Property Set: ${pset.Name}`);
const propIds = pset.HasProperties as number[];
for (const propId of propIds) {
const prop = model.get(propId);
if (prop) {
console.log(` ${prop.Name} = ${prop.NominalValue}`);
}
}
}import { createQuantitySet } from '@ifc-factory/core';
const qset = createQuantitySet(model, 'Qto_WallBaseQuantities', [
{ name: 'Length', value: 12.0, quantityType: 'LENGTH' },
{ name: 'Height', value: 3.0, quantityType: 'LENGTH' },
{ name: 'Width', value: 0.3, quantityType: 'LENGTH' },
{ name: 'GrossArea', value: 36.0, quantityType: 'AREA' },
{ name: 'NetArea', value: 32.4, quantityType: 'AREA' },
{ name: 'GrossVolume', value: 10.8, quantityType: 'VOLUME' },
{ name: 'NetVolume', value: 9.72, quantityType: 'VOLUME' },
{ name: 'GrossWeight', value: 25920.0, quantityType: 'WEIGHT' },
]);
assignPropertySet(model, qset.expressID, [wallId]);Supported quantityType values: 'LENGTH', 'AREA', 'VOLUME', 'WEIGHT', 'COUNT', 'TIME'
import { createDocumentInformation, createDocumentReference, associateDocument } from '@ifc-factory/core';
// Create document information
const doc = createDocumentInformation(model, {
name: 'Constructietekening K-001',
description: 'Keldervloer constructiedetails',
location: 'https://docs.example.com/K-001.pdf',
});
// Associate with elements
associateDocument(model, doc.expressID, [slabId, columnId]);
// Create a document reference (lightweight)
const docRef = createDocumentReference(model, {
name: 'Brandveiligheidscertificaat',
location: '/certificates/fire-safety-2024.pdf',
identification: 'CERT-2024-042',
});import { createLibraryInformation, createLibraryReference, associateLibrary } from '@ifc-factory/core';
// Create library
const lib = createLibraryInformation(model, {
name: 'STABU Besteksystematiek',
version: '2024',
description: 'Nederlandse bestekssystematiek voor de bouw',
});
// Create reference to a specific item in the library
const libRef = createLibraryReference(model, {
name: 'Metselwerk baksteen',
identification: '22.21.10',
libraryId: lib.expressID,
});
// Associate with elements
associateLibrary(model, libRef.expressID, [wallId]);import { createClassification, createClassificationReference, associateClassification } from '@ifc-factory/core';
// Create classification system
const nlsfb = createClassification(model, {
name: 'NL-SfB',
edition: '2005',
source: 'BIM Loket',
});
// Create a specific classification reference
const ref = createClassificationReference(model, {
identification: '21.22',
name: 'Buitenwanden; niet-dragende wanden',
classificationId: nlsfb.expressID,
});
// Associate with elements
associateClassification(model, ref.expressID, [wall1Id, wall2Id]);
// Multiple classification systems
const omniclass = createClassification(model, {
name: 'OmniClass',
edition: '2019',
source: 'CSI',
});
const omniRef = createClassificationReference(model, {
identification: '23-13 17 11',
name: 'Cast-in-Place Concrete Wall Formwork',
classificationId: omniclass.expressID,
});
associateClassification(model, omniRef.expressID, [wall1Id]);import { createAnnotation, createTextLiteral } from '@ifc-factory/core';
// Create an annotation
const annotation = createAnnotation(model, {
name: 'Room Label',
});
// Create a text literal with placement
const text = createTextLiteral(model, {
literal: 'Woonkamer\n24.5 m²',
placement: { x: 5.0, y: 3.0 },
});import {
createRelAggregates,
createRelAssociatesMaterial,
createRelAssociatesClassification,
createRelAssociatesDocument,
createRelAssociatesLibrary,
} from '@ifc-factory/core';
// Aggregation (parent → children decomposition)
createRelAggregates(model, buildingId, [storey1Id, storey2Id]);
// Material association
createRelAssociatesMaterial(model, materialId, [wallId, slabId]);
// Classification association
createRelAssociatesClassification(model, classRefId, [wallId]);
// Document association
createRelAssociatesDocument(model, docId, [wallId, doorId]);
// Library association
createRelAssociatesLibrary(model, libRefId, [wallId]);import { generateIfcGuid } from '@ifc-factory/core';
// Generate a single IFC GUID (22-char base64)
const guid = generateIfcGuid();
// e.g., '2TGt$H0E5Cexq0Fmv1x7tP'
// GUIDs are unique and use IFC's custom base64 alphabet:
// 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$Built-in support for BBL, BENG, and Aerius property sets. See Dutch Compliance for full documentation.
import { createBBLPropertySet, createBENGPropertySet, createAeriusPropertySet } from '@ifc-factory/core';
// Fire safety
createBBLPropertySet(model, [wallId], { brandklasse: 'A1', brandwerendheid: 60 });
// Energy performance
createBENGPropertySet(model, [buildingId], { energieBehoefte: 25.0, primairFossieleEnergie: 50.0 });
// Nitrogen
createAeriusPropertySet(model, [projectId], { stikstofEmissie: 1.5, projectId: 'AERIUS-2024-001' });See Query API for full documentation.
import { QueryBuilder, byType, byProperty, and } from '@ifc-factory/core';
const results = new QueryBuilder(model)
.ofType('IfcWall')
.whereProperty('Name', 'Exterior Wall')
.limit(10)
.execute();| Method/Property | Returns | Description |
|---|---|---|
IfcModel.fromStep(source) |
IfcModel |
Parse STEP string |
model.toStep() |
string |
Serialize to STEP |
model.get(id) |
IfcGenericEntity | undefined |
Get entity |
model.create(type, attrs) |
IfcGenericEntity |
Create entity |
model.update(id, changes) |
void |
Update entity |
model.delete(id) |
void |
Delete entity |
model.getAllOfType(type) |
IfcGenericEntity[] |
Find by type |
model.getSpatialTree() |
SpatialTreeNode |
Spatial hierarchy |
model.getAggregateChildren(id) |
IfcGenericEntity[] |
Aggregate children |
model.getContainedElements(id) |
IfcGenericEntity[] |
Contained elements |
model.containInSpatialStructure(spatialId, elementId) |
void |
Place element |
model.project |
IfcGenericEntity | undefined |
IfcProject |
model.size |
number |
Entity count |
model.schema |
string |
Schema ID |
| Function | Description |
|---|---|
createSpatialStructure(model, options) |
Build project/site/building/storeys |
flattenSpatialTree(tree) |
Flatten to array |
createPropertySet(model, name, props) |
Create IfcPropertySet |
createQuantitySet(model, name, quantities) |
Create IfcElementQuantity |
assignPropertySet(model, psetId, elementIds) |
Assign pset |
getPropertySets(model, elementId) |
Get psets |
createDocumentInformation(model, options) |
Create document |
createDocumentReference(model, options) |
Create doc reference |
associateDocument(model, docId, elementIds) |
Associate document |
createLibraryInformation(model, options) |
Create library |
createLibraryReference(model, options) |
Create lib reference |
associateLibrary(model, libId, elementIds) |
Associate library |
createClassification(model, options) |
Create classification |
createClassificationReference(model, options) |
Create class reference |
associateClassification(model, refId, elementIds) |
Associate classification |
createAnnotation(model, options) |
Create annotation |
createTextLiteral(model, options) |
Create text |
createRelAggregates(model, parentId, childIds) |
Create aggregation |
generateIfcGuid() |
Generate IFC GUID |
createBBLPropertySet(model, elementIds, data) |
BBL fire safety |
createBENGPropertySet(model, elementIds, data) |
BENG energy |
createAeriusPropertySet(model, elementIds, data) |
Aerius nitrogen |
- API Reference — Consolidated reference across all packages
- Query API — Fluent query builder
- Dutch Compliance — BBL, BENG, Aerius details
- Tutorials — Step-by-step examples
Ifc-Factory
Getting Started
Concepts
Packages
API & Reference
Development