Read an IFC building

Read an IFC building#

IFC (Industry Foundation Classes) is the dominant interchange format for buildings and infrastructure (BIM). This example loads a real BIM model, the buildingSMART “Single-family house” sample (CC-BY 4.0, buildingSMART International), and confirms that every product becomes one block in a pyvista.MultiBlock with cad.guid, cad.ifc_type, cad.label, and cad.material field data attached.

Why this matters: a typical BIM workflow starts by filtering an IFC by IfcType (walls vs. slabs vs. mechanical) before any further analysis. The .cad accessor’s find is built for exactly that.

import pandas as pd
import pyvista as pv

import pyvista_cad
from pyvista_cad.examples import downloads

Read the real IFC building.

MultiBlock (0x7f6fa9291b40)
  N Blocks:   5
  X Bounds:   -2.964e+01, 8.900e+00
  Y Bounds:   -1.499e+01, 9.300e+00
  Z Bounds:   -1.300e+00, 5.700e+00


Real BIM exports carry stray markers: this file has a geo-reference point and a survey origin, both placed far from the house. They have no reliable IFC class (generic IfcBuildingElementProxy), so drop_spatial_outliers removes them by a robust MAD test on block position instead of by name.

mb = mb.cad.drop_spatial_outliers()

Filter by IFC type using the .cad accessor: the canonical BIM pattern: pull every wall out of an arbitrary-depth building.

walls = mb.cad.find(ifc_type='IfcWall')
pd.DataFrame({'path': [str(p) for p, _ in walls]})
path
0 environment - site/house - site/Single-family ...
1 environment - site/house - site/Single-family ...
2 environment - site/house - site/Single-family ...
3 environment - site/house - site/Single-family ...


Render with one color per element.

pl = pv.Plotter()
pl.add_mesh(mb, multi_colors=True, show_edges=True, edge_color='black')
pl.show()
read ifc

Total running time of the script: (0 minutes 1.926 seconds)