Skip to content

Convert IFC to glTF, COLLADA or CityJSON with IfcConvert

Feature Group: Convert, Host | IfcOpenShell / IfcConvert

Introduction

Different conversions are available with IfcConvert (part of IfcOpenShell) and detailed in IfcConvert - Usage

This includes:

  • Collada (.dae). 3D models of buildings, bridges, monuments can be imported in KML (Key Markup Language) with the COLLADA interchange file format. This means the model can be displayed on Google Earth or Cesium.
  • glTF (.glb). Same as above with a new format. Supported in Cesium.
  • CityJson. A recent addition to the IfcConvert stack. The CityJSON model can be imported in Geo products designed to manage and render CityGML models. E.g. 3DCityDB which also can import Collada and glTF files.

Caveats

IfcConvert is not a library but an executable that needs to be run from a Celery task in a subprocess.

Because multiple types of issues can occur, a timeout is configured on the subprocess to avoid that the Celery worker gets stuck.

The timeout if defined in the request with a default of 60 sec and has configured lower and uper bounds.

When the bundleId and the unitId are provided, the converted file can be registered in the database in the unitjson column of the bundleunit.

#
#  Convert an IFC to glTF, COLLADA or CityJSON
#
class IfcConvert_Instruction(BaseModel):
    sourceFileURL: str | None = NONE_IFC_URL
    targetFormat: Literal['glTF','COLLADA','CityJSON']
    timeout: Optional[int] = Field(60, ge=30, le=180)
    bundleId: str | None = None
    unitId: str | None = None

class IfcConvert_Result(BaseModel):
    resultPath: str # relative path of the result file (gltf, dae, or json)
    runtime: float | None = 0.0 # in seconds

Examples

Conversion of Duplex_A_20110907_optimized.ifc to Collada

With Online 3D Viewer

Duplex_A_20110907_optimized.dae with Online 3D Viewer

Conversion of Duplex_A_20110907_optimized.ifc to glTF

Same viewer

Duplex_A_20110907_optimized.glb with Online 3D Viewer

Conversion to glTF of Duplex-A (apartment) extracted as a SpatialZone from Duplex_A_20110907_optimized

Duplex-A.glb with Online 3D Viewer

Same but with some meshes hidden in Online 3D Viewer to see the inside of the apartment

Duplex-A.glb with some hidden meshes in Online 3D Viewer

Conversion to CityJSON

This originates from the paper Automatic conversion of IFC datasets to geometrically and semantically correct CityGML LOD3 buildings (../features/references.md#ifc-to-citygml).

The code was originally published on https://github.com/tudelft3d/ifc2citygml, thenafter on https://github.com/tudelft3d/esri_geobim, then enventually made available under the umbrella of IfcOpenShell on https://github.com/IfcOpenShell/ifc-to-cityjson.

The functionality has been integrated into IfcConvert. Downloads are available at IfcConvert Download

The CityJSON version outputted is 1.0 and is outdated. It is possible to upgrade the version to 2.0 with the cityjson toolkit cjio There is also an online CityJSON Validator.

Conversion of Duplex_A_20110907_optimized.ifc to CityJSON

With ninja viewer of which the code is available on github

Duplex_A_20110907_optimized.cityjson with ninja viewer

Issue: Conversion of IFC_Schependomlaan from IFC to CityJSON failed

Last login: Thu Oct 24 22:21:23 on ttys042
IfcOpenShell IfcConvert 0.7.11-03935a91d (OCC 7.5.3)
Scanning file...
Done scanning file   
CGAL error: assertion violation!
Expression : 
File       : /Users/hetzner/IfcOpenShell_v0.8.0/build/Darwin/arm64/10.9/install/cgal-5.3/include/CGAL/Nef_3/SNC_const_decorator.h
Line       : 276
Explanation: it is not possible to decide which one is a visible facet (if any)
Refer to the bug-reporting instructions at https://www.cgal.org/bug_report.html

The conversion completes reasonably fast on relatively simple models.

For complex models such as IFC_Schependomlaan or ARK_NordicLCA_Housing_Concrete_BuildingPermit_Revit, running the conversion on the extracted envelope was not successful either.