XbimEssentials
A .NET library to work with data in the IFC format. This is the core component of the Xbim Toolkit
Install / Use
/learn @xBimTeam/XbimEssentialsREADME
Branch | Build Status | MyGet | NuGet
------ | ------- | --- | --- |
Master | |
|
Develop |
|
| -
|Toolkit Component| Latest Myget (develop) | Latest Myget (master) | Latest Nuget |
| ----| ---- | ----| ---- |
|Essentials| |
|
|Geometry|
|
|
|CobieExpress|
|
|
|Windows UI|
|
|
|Exchange|
|
|
XbimEssentials
XbimEssentials is the foundational components of Xbim, the eXtensible Building Information Modelling toolkit for the .NET platform. This library enables software developers to easily read, write, validate and interrogate data in the buildingSmart IFC formats, using any .NET language.
As of version 6.0 XbimEssentials includes support for .netstandard2.0, .netstandard2.1, .net6.0 and net8.0.
Supporting netstandard2.0 provides support .NET Framework 4.7.2 upwards.
Earlier .NET Framework versions may work, but we can't provide any support for them.
Background / Motivation
IFC is an ISO Standard and platform-neutral open file format for data exchange of building information. This library supports STEP, IfcXml and IfcZip formats, and enables you to read and write the full schema of IFC2x3 and IFC4 (including support for the latest Ifc4 Addendum 2).
The wider XBIM toolkit contains additional repositories with libraries to read and write related Open BIM formats including COBie and BIM Collaboration Format (BCF)
xbim Toolkit also supports IFC model verification with IDS using our IDS Library.
In order to visualise 3D Geometries you will need to include the Xbim.Geometry package which provides full support for geometric, topological operations and visualisation.
The motivation behind XbimEssentials is to take away much of the complexity and 'heavy lifting' required to read and write OpenBIM file formats, so you can focus on creating software solutions without needing deep understanding of STEP/Express parsing, 3D graphics - enabling you to work at a higher level than the buildingSmart data model.
Updating from prior versions
Please see our ChangeLog for details on what's new and what you need to upgrade. In particular, please note the following section copied here:
BREAKING CHANGE: xbim Toolkit V6 implements a new mechanism for registering internal resources and makes use of standard .net Dependency Injection patterns for managing services internally.
Xbim.Commonnow introduces an internal DI service that you can optionally integrate with your own DI implementation, for providing Logging services, and configuring xbim service behaviour such as the model provider to use. E.g. Invoking:
XbimServices.Current.ConfigureServices(s => s.AddXbimToolkit(opt => opt.UseMemoryModel().UseLoggerFactory(yourloggerFactory)));registers the Toolkit internal dependencies, configures an In-memory model-provider and adds an existing ILoggerFactory into the service in place of our default one.
IfcStore.ModelProviderFactoryhas been deprecated as this is provided for by the above mechanism The persistent EsentModel is now available automatically through IfcStore (on Windows) so there is no need for theUseHeuristicModelProvider()'ceremony' to ensure Esent is used although you can specify it explicitly withXbimServices.Current.ConfigureServices(s => s.AddXbimToolkit(opt => opt.UseHeuristicModel())Note: The default Logging implementation has been removed from Toolkit to reduce the amount of external dependencies. To enable is a simple matter of adding your preferred logging implementation to the Xbim Services. See Example
Code Examples
If you want to jump straight in we have some examples on our docs site. But here's a 60 second tour of reading and writing:
1. Reading data
Given an IFC File SampleHouse.ifc exported from a tool such as Revit, this is a simple example showing how you'd read and extract data, using LINQ:
const string fileName = "SampleHouse.ifc";
using (var model = IfcStore.Open(fileName))
{
// get all doors in the model (using IFC4 interface of IfcDoor - this will work both for IFC2x3 and IFC4)
var allDoors = model.Instances.OfType<IIfcDoor>();
// get only doors with defined IIfcTypeObject
var typedDoors = model.Instances.Where<IIfcDoor>(d => d.IsTypedBy.Any());
// get one single door by its unique identifier / guid
var id = "2AswZfru1AdAiKfEdrNPnu";
var theDoor = model.Instances.FirstOrDefault<IIfcDoor>(d => d.GlobalId == id);
Console.WriteLine($"Door ID: {theDoor.GlobalId}, Name: {theDoor.Name}");
// get all basic properties of the door
var properties = theDoor.IsDefinedBy
.Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
.SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties)
.OfType<IIfcPropertySingleValue>();
foreach (var property in properties)
Console.WriteLine($"Property: {property.Name}, Value: {property.NominalValue}");
}
... resulting in output like:
Door ID: 3cUkl32yn9qRSPvBJVyWYp, Name: Doors_ExtDbl_Flush:1810x2110mm:285860
Property: IsExternal, Value: true
Property: Reference, Value: 1810x2110mm
Property: Level, Value: Level: Ground Floor
Property: Sill Height, Value: 0
Property: Area, Value: 4.9462127188431
Property: Volume, Value: 0.193819981582386
Property: Mark, Value: 1
Property: Category, Value: Doors
Property: Family, Value: Doors_ExtDbl_Flush: 1810x2110mm
Property: Family and Type, Value: Doors_ExtDbl_Flush: 1810x2110mm
Property: Head Height, Value: 2110
Property: Host Id, Value: Basic Wall: Wall-Ext_102Bwk-75Ins-100LBlk-12P
Property: Type, Value: Doors_ExtDbl_Flush: 1810x2110mm
Property: Type Id, Value: Doors_ExtDbl_Flush: 1810x2110mm
Property: Phase Created, Value: New Construction
2. Amending data
In this simple example we're going to add a 'purchase cost' property to a single Door. We could have applied the cost against the Door Type if all instances of it shared the property.
const string fileName = "SampleHouse.ifc";
var editor = new XbimEditorCredentials
{
ApplicationDevelopersName = "EZ Bim Apps Inc",
ApplicationFullName = "My BIM App",
ApplicationIdentifier = "my-bim-app",
ApplicationVersion = "1.0",
EditorsFamilyName = "John",
EditorsGivenName = "Doe",
EditorsOrganisationName = "Acme Consultants Inc"
};
using (var model = IfcStore.Open(fileName, editor, true))
{
// get an existing door from the model
var id = "3cUkl32yn9qRSPvBJVyWYp";
var theDoor = model.Instances.FirstOrDefault<IfcDoor>(d => d.GlobalId == id);
// open transaction for changes
using (var txn = model.BeginTransaction("Doors modification"))
{
// create new property set to host prope
