0.3.8 • Published 11 months ago

ifc-lbd v0.3.8

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

IFC to LBD

IFC to Linked Building Data (LBD) is built on IFC.js. It uses the web-ifc model loader and parses out triples in JSON-LD format.

demo

Install

npm i ifc-lbd

Why

Working with IFC in the express file format, and therefore the IFC.js project is like sent from the sky. It provides tools that make it a whole lot easier to retrieve properties and traverse the relationships of the IFC file, but even so, it is still a cumbersome job to work with IFC.

The minimal Building Topology Ontology (BOT), however, is quite straightforward to understand, and having a BOT dataset in RDF is cool because it allows you to do sophisticated queries it with SPARQL. The resulting JSON-LD-object can furthermore be re-structured using the cool concepts of compaction, expansion and framing. For example, it might be useful to use framing to build a simple tree structure of the graph as demonstrated below:

const frame = {
  "@context": {
    "bot": "https://w3id.org/bot#",
    "ex": "https://example.com/"
  },
  "@type": "bot:Building",
  "bot:hasStorey": {
    "@type": "bot:Storey",
    "bot:hasSpace": {
      "@type": "bot:Space"
    }
  }
}

const framed = await jsonld.frame(botTriples, frame);

Use

The IFC-LBD parser can be used in a JavaScript project or can be used as a CLI tool.

CLI Tool

Install globally on your machine npm i -g ifc-lbd

Run a subset (BOT, products) ifc-lbd [subset] -i ./myFile.ifc

NB! If used in Node 18, you currently need to set the --no-experimental-fetch flag when executing the command. But how to do this with a globally installed command?

See settings ifc-lbd -h

Run in dev node --no-experimental-fetch ./dist/cli-index.cjs bot -i ./tests/artifacts/Duplex.ifc

Building Topology Ontology (BOT)

Exports triples in compliance with the Building Topology Ontology.

// Init API and load model
const ifcApi = new WebIFC.IfcAPI();
await ifcApi.Init();
const modelID = ifcApi.OpenModel(ifcModelData);

// Init LBD Parser and parse BOT
const lbdParser = new LBDParser();
const botTriples = await lbdParser.parseBOTTriples(ifcApi, modelID);

// Close the model, all memory is freed
ifcApi.CloseModel(modelID);

Flow Systems Ontology (FSO)

Exports triples in compliance with the Flow Systems Ontology. In addition, ports are also exported and the center points of these are exported as OMG geometries. Pipe lengths are calculated from the distance between its two ports.

Coordinates and lengths are normalized to meters.

// Init LBD Parser and parse FSO
const lbdParser = new LBDParser();
const fsoTriples = await lbdParser.parseFSOTriples(ifcApi, modelID);

Flow Systems Ontology (FSO)

Exports triples in compliance with the TUBES System Ontology. This is a Work in Progress and currently only supports few concepts.

// Init LBD Parser and parse FSO
const lbdParser = new LBDParser();
const fsoTriples = await lbdParser.parseFSOTriples(ifcApi, modelID);

IFC Products

// Init LBD Parser and parse products
const lbdParser = new LBDParser();
const products = await lbdParser.parseProductTriples(ifcApi, modelID);

IFC Properties

All measurements (lengths, areas, volumes) are normalized to SI-units (m, m2, m3).

// Init LBD Parser and parse properties
const lbdParser = new LBDParser();
const properties = await lbdParser.parsePropertyTriples(ifcApi, modelID);

Contribute

This library is intended to be expanded, so please go and add your parser or extend one of the existing ones!

Remember to write tests! That's also the preferred approach to developing new functionalities. Run specific test: npm run test -i <path> (eg jest -i tests/fso.spec.ts)

NB! Due to a bug in web-ifc I had to do a hardcoded fix by changing doing a find/replace in node_modules/web-ifc/web-ifc-api-node.js and node_modules/web-ifc/web-ifc-api-browser.js:

Find:

].map((p) => p.value)

Replace:

]?.map((p) => p.value)

Stats

Execute like node ./lib/cli-tool/index.js bot -i ./tests/artifacts/Duplex.ifc

For triple count, copy resulting JSON-LD to JSON-LD Playground and convert to N-Quads + get line count.

ModelDuplex (2,4MB)MEP(962KB)Schependomlaan(49,3MB)Office MEP(209,1MB)
BOTms3413128349
BOTtriples1,71817512,25133,087
FSOms-55-165
FSOtriples-2,386-32,024
Productsms9846174
Productstriples218853,63516,012
Propertiesms161483,066
Propertiestriples15,5061,401266,391

Units

In the current setup, all units are as defined in the input model. Will be neutralized to the following in a future release:

MeasureUnit
Distancemm
Aream2
Volumem3
0.3.6

11 months ago

0.3.8

11 months ago

0.3.7

11 months ago

0.3.5

12 months ago

0.3.2

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.2.3

1 year ago

0.3.1

1 year ago

0.2.2

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

2 years ago

0.1.2

2 years ago

0.1.3

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago