Skip to content

Creating Files for Offline BIM

xeolabs edited this page Mar 25, 2020 · 31 revisions

See also:

Introduction

In this tutorial you'll learn how to convert your model from an IFC STEP file (either IFC2x3 or IFC4) to geometry and metadata files that can be efficiently loaded into xeokit, straight off the file system, without relying on cloud storage or a BIM model server.

To view your model, you can then use xeokit-bim-viewer, which is the fastest way to get your model on the Web. To use that option, you just need to fork that repository, drop in your model, add some JSON to register it, and you're good to go.

Or, if you're building your custom viewer, you can plug it together yourself from xeokit SDK components and plugins, as described in Viewing BIM Models Offline.

Contents

Creating an XKT Model

1. Download an IFC File

We'll use an IFC2x3 model from the OTC Conference Center dataset. Note that we could also use IFC4.

Note that, for this tutorial, we've renamed our IFC file to OTCConferenceCenter.ifc, just to strip out the spaces in the filename and make it more readable.

2. Install CLI Tools

We'll use these CLI tools to transform the IFC file into an .XKT file:

We'll assume that these are installed relative to the current working directory.

3. Convert IFC to COLLADA

Convert the IFC file into a COLLADA file:

./IfcConvert --use-element-guids OTCConferenceCenter.ifc OTCConferenceCenter.dae

Note the use-element-guids option, which ensures that the IFC product IDs are preserved in the glTF.

3.1. Centering the Model

Sometimes the coordinates within an IFC model are translated far from the origin, which can cause the model to become distorted when later converted into XKT format (see Step 5 below).

If that happens, try adding the --center-model option, which makes IfcConvert center the model at [0,0,0]:

./IfcConvert --use-element-guids --center-model OTCConferenceCenter.ifc OTCConferenceCenter.dae

3.2 Missing IfcSpaces?

Sometimes IfcSpace elements may be missing in your converted model.

IfcConvert will exclude IfcSpace elements by default. Try running it with an --exclude=entities argument, to explicitly override that exclusion. Make sure that argument is the last argument on the command.

ifcconvert --use-element-guids OTCConferenceCenter.ifc OTCConferenceCenter.dae --exclude=entities IfcOpeningElement

4. Convert COLLADA to glTF

Then convert the COLLADA into a glTF 2.0 file:

./COLLADA2GLTF/build/COLLADA2GLTF-bin -i OTCConferenceCenter.dae -o OTCConferenceCenter.gltf

The glTF file will be a single text file with its geometry data embedded within it.

5. Convert glTF to XKT

Now convert the glTF into an XKT file:

gltf2xkt.js -s OTCConferenceCenter.gltf -o OTCConferenceCenter.xkt

or

node gltf2xkt.js -s OTCConferenceCenter.gltf -o OTCConferenceCenter.xkt

Now we have the model geometry in a compact format that can be loaded efficiently into xeokit. Next, we'll create the JSON metadata file that we'll be loading alongside the XKT file.

Creating JSON IFC Metadata

1. Install CLI Tool

Download and install xeokit-metadata, which we'll use to extract the structural hierarchy of the building elements within an IFC file into xeokit's metadata format.

2. Convert IFC to JSON Metadata

xeokit-metadata OTCConferenceCenter.ifc OTCConferenceCenter.json

Viewing the Model

Now we have an XKT file that describes the model geometry, along with a JSON file that specifies metadata for it.

At this point, as mentioned, we have two options for getting our BIM model on the Web:

  1. deploy the model in a fork of xeokit-bim-viewer, xeokit's bundled IFC viewer, or
  2. create our own viewer using xeokit components, as described in Viewing BIM Models Offline.

Need Help?

Everything here is well-tested and used in production by a bunch of xeokit users, so we're confident that this process can work well for you.

Sometimes, however, users have benefited from a short consultation to get them started.

xeolabs can help you with:

  • Identifying issues in your IFC models
  • Optimizing your models for fast loading and rendering
  • Setting up the model conversion tools
  • Setting up a xeokit-bim-viewer with your models
  • Pointers on using the xeokit SDK to build your custom solution

Get in touch if you could use a little help getting started.

Clone this wiki locally