Calculate Differences of IFC files with Hashing

Purpose

The goal of this tutorial is to learn how to asses whether 2 successively exported IFC building models are different by testing whether entity instances of the latest are present in the original one or entity instances of the original one are present in the latest version.

The data is stored using the Industry Foundation Class (IFC) format, which is the standard format to digitally represent anything related to the construction industry. This format stands as an open-standard, and enables to share building models in form of IFC files between the different actors of a construction project. We can think of IFC as the PDF for the construction industry.

For example, how could you find the difference between those 2 files?

Read more…

IfcOpenShell Optimizer tutorial

Purpose

The goal of this tutorial is to reduce the size of an IFC file. Indeed, IFC files can become rather large and processing them can lead to expensive computational costs. Most of the time, this important size is due to duplicate entity instances. In this tutorial, we're going to see how to create a newly optimized file which doesn't contain those instances.

Read more…

Using IfcOpenShell and C++ to generate Alignments through the IFC 4x1 schema

IfcOpenShell has an EXPRESS parser and code generator that generates code for the various IFC schemas. As part of the source code repository comes pre-generated code for the two widely used versions IFC2X3 and IFC4. But arbitrary schemas can be fed into the parser to provide support for other schemas at compile time. This post highlights the process of generating code for other schemas and talks about the recent developments within the IFC Alignment project._

Illustration of an alignment as exchanged in IFC

Read more…

Creating a simple wall with property set and quantity information

The following recipe creates a simple wall from scratch using a templating technique to quickly populate the entity instances for the IFC project structure. Simple extrusion geometries, an IfcPropertySet and an IfcElementQuantity are added using the procedural entity instance creation functions. The script is written for a research project with Dr. Patrick Janssen in National University of Singapore. The script takes reference from the FreeCAD IFC exporter script and HelloWall miniExample.

HelloWall

Read more…

Using IfcOpenshell and pythonOCC to generate cross sections directly from an IFC file

[This article contains several snippets of source code for illustration purposes, the full source code can be downloaded at the bottom]

Section information can be used for multiple purposes. This example is the first part of a project in which the aim is to be able to directly send information to a large 3D concrete printer. This printer will be able to print concrete buildings on a 1:1 scale on a building site. The goal is to control the printer directly from an IFC model. Since the printer will print one layer at a time, the first step is to derive section information from an IFC file. This is what this tutorial is about. As an example of the information that can be deduced from a section, the area that needs to be printed is calculated.

This example builds upon some of the concepts in "Using IfcOpenShell and pythonOCC to construct new geometry" and uses the same model of a simple house, called IfcOpenHouse.

Read more…

Using the parsing functionality of IfcOpenShell interactively

In this recipe we are going to look at an interactive way of working with Python and IfcOpenShell that allows to quickly explore the possibilities offered by the tools. When the python interpreter (python.exe) is executed without arguments it will function as a REPL (a Read Evaluate Print Loop). It enables the user to type a single line of code and immediately see the evaluated result. An example of such a session is provided below. It outlines the procedure of starting with an IfcProject and descending down to the unit for angular measures. In this particular file it seems that angles are specified as degrees, a constant factor of 0.0174533 away from radians.

Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ifcopenshell
>>> file = ifcopenshell.open("IfcOpenHouse.ifc")
>>> project = file.by_type("IfcProject")[0]
>>> project
#18=IfcProject('2f0veX5Vj59AhEg6WqGnhO',#5,'IfcOpenHouse',$,$,$,$,(#11),#17)
>>> project.is_a()
'IfcProject'
>>> project.is_a("IfcRoot")
True
>>> project.is_a("IfcWall")
False
>>> project.id()
18
>>> project.attribute_name(0)
'GlobalId'
>>> project.attribute_type(0)
'STRING'
>>> project.GlobalId
'2f0veX5Vj59AhEg6WqGnhO'
>>> project.Bier
Traceback (most recent call last):
  File "", line 1, in 
  File "ifcopenshell\\ifcopenshell.py", line 28, in __getattr__
    except: raise AttributeError("entity instance of type '%s' has no attribute '%s'"%(self.wrapped_data.is_a(), name))
AttributeError: entity instance of type 'IfcProject' has no attribute 'Bier'
>>> project.UnitsInContext
#17=IfcUnitAssignment((#13,#16))
>>> units = project.UnitsInContext.Units
>>> angle_unit = filter(lambda u: u.UnitType == "PLANEANGLEUNIT", units)[0]
>>> angle_unit
#16=IfcConversionBasedUnit(#12,.PLANEANGLEUNIT.,'Degrees',#15)
>>> angle_unit.ConversionFactor
#15=IfcMeasureWithUnit(IfcPlaneAngleMeasure(0.0174533),#14)
>>> angle_unit.ConversionFactor.ValueComponent
IfcPlaneAngleMeasure(0.0174533)
>>> angle_unit.ConversionFactor.ValueComponent.is_a()
'IfcPlaneAngleMeasure'
>>> angle_unit.ConversionFactor.ValueComponent.wrappedValue
0.0174533