IfcOpenShell
Description
IfcOpenShell is an open source (LGPL 3) software library that helps developers work with the industry foundation classes (IFC) file format. The IFC file format can be used to describe building and construction data. The format is commonly used for building information modelling (BIM), for example, mechanical loading analysis and thermal studies. IfcOpenShell is primarily a collection of C++ libraries, however, as it has Python bindings, it can be easily integrated with programs like FreeCAD and Blender.
IfcOpenShell uses OpenCASCADE internally to convert the implicit geometry in IFC files into explicit geometry that other CAD packages can understand.
As of v0.19, FreeCAD is able to import IFC files as long as the ifcopenshell
Python module is available in the system. Likewise, the Arch and BIM Workbenches can export a building model to the IFC format so that it can be used in other applications.
To verify that IfcOpenShell is installed in your system, try to import it from the Python console; the library is correctly installed if no error message is returned.
import ifcopenshell
Installation
IfcOpenShell can be installed in various ways depending on your operating system.
Conda
For Windows and MacOS users, which use the Conda-based FreeCAD distributions, IfcOpenShell is usually included in the respective package so normally no further installation is necessary. Get this distribution from the Download page.
The AppImage available for Linux is also based on Conda, and it also includes IfcOpenShell.
Linux
You may install IfcOpenShell from your local package manager, if it is available.
sudo apt install ifcopenshell
However, please remember that the package provided by a repository may be out of date. In this case, use a Conda-based distribution of FreeCAD, or compile IfcOpenShell yourself.
Compiling
Compiling IfcOpenShell is recommended only for advanced users. The process uses the CMake configuration tool to produce a custom Makefile for use with the Make tool. The general instructions are outlined in the code repository.
The general steps are as follows:
- Get the source code of IfcOpenShell from its main repository.
- Gather all dependencies for compiling, including installing a C++ compiler, CMake, and Make, and the development files for Boost, libxml2, OpenCASCADE, SWIG, Python, and OpenCOLLADA (optional). Most of these components are strictly optional, however, for use with FreeCAD they should all be installed except for OpenCOLLADA, as it only provides support for DAE files.
- Run
cmake
to generate aMakefile
, then compile the libraries by runningmake
. - Install the
ifcopenshell
Python module in the appropriatesite-packages
directory so that it is found by FreeCAD.
Prerequisites
Get the source code of the project and place it in a custom directory to which you have full write access.
As of this writing (2020), the master branch of the IfcOpenShell project does not contain the latest code, so we need to clone a specific branch.
git clone https://github.com/IfcOpenShell/IfcOpenShell -b v0.6.0 ifcopenshell-source
Install the basic compilation tools.
sudo apt install git cmake gcc g++ libboost-all-dev
OpenCASCADE
Install the development files of OpenCASCADE.
sudo apt install libocct*-dev
Which expands to
sudo apt install libocct-data-exchange-dev libocct-draw-dev libocct-foundation-dev libocct-modeling-algorithms-dev libocct-modeling-data-dev libocct-ocaf-dev libocct-visualization-dev
You may use the community edition (OCE) of OpenCASCADE as well, however, please notice that this version is old and no longer recommended by FreeCAD as of 2020.
Python wrapper
For usage with FreeCAD you need the Python wrapper which uses SWIG to generate the proper interfaces from the C++ classes.
sudo apt-get install python-all-dev swig
CMake configuration
It is recommended to perform the compilation in a specific build directory.
mkdir -p ifcopenshell-build
cd ifcopenshell-build
cmake ../ifcopenshell-source/cmake/
Notice that the CMakeLists.txt
file that drives CMake is inside the cmake/
directory.
Depending on your Linux distribution, and the way you installed the dependencies, you may have to define some CMake variables so that the proper libraries are found.
Specifying the OpenCASCADE libraries
If you manually compiled OpenCASCADE, or if the libraries are not in a standard directory, you may have to set up the proper variables.
cmake \
-DOCC_INCLUDE_DIR=/usr/include/opencascade \
-DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
../ifcopenshell-source/cmake/
Specifying the libxml2 libraries
If the libxml2 libraries are not found, or if the libraries are not in a standard directory, you may have to set up the proper variables.
cmake \
-DOCC_INCLUDE_DIR=/usr/include/opencascade \
-DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
-DLIBXML2_INCLUDE_DIR=/usr/include/libxml2 \
-DLIBXML2_LIBRARIES=/usr/lib/x86_64-linux-gnu/libxml2.so \
../ifcopenshell-source/cmake/
Without OpenCOLLADA
If you don't need OpenCOLLADA support you need to turn it off explicitly.
cmake \
-DOCC_INCLUDE_DIR=/usr/include/opencascade \
-DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
-DLIBXML2_INCLUDE_DIR=/usr/include/libxml2 \
-DLIBXML2_LIBRARIES=/usr/lib/x86_64-linux-gnu/libxml2.so \
-DCOLLADA_SUPPORT=FALSE \
../ifcopenshell-source/cmake/
With OpenCOLLADA
If you manually compiled OpenCOLLADA, or if the libraries are not in a standard directory, you may have to set up the proper variables.
cmake \
-DOCC_INCLUDE_DIR=/usr/include/opencascade \
-DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
-DLIBXML2_INCLUDE_DIR=/usr/include/libxml2 \
-DLIBXML2_LIBRARIES=/usr/lib/x86_64-linux-gnu/libxml2.so \
-DOPENCOLLADA_INCLUDE_DIR=/usr/local/include/opencollada \
-DOPENCOLLADA_LIBRARY_DIR=/usr/local/lib/opencollada \
-DPCRE_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/
../ifcopenshell-source/cmake/
Troubleshooting and other options
All configuration options are available in the CMakeLists.txt
file located inside the cmake/
directory. You may look for other options that can be set here if there are problem when running CMake.
Installing
If the configuration doesn't report any error, you may install the compiled shared and static libraries to the corresponding directories.
sudo make install
By default, the CMAKE_INSTALL_PREFIX
is /usr/local
, so all compiled files will be tried to be installed to this directory, which normally requires elevated privileges.
/usr/local/bin
/usr/local/include
/usr/local/lib
In similar way, the Python wrapper will be placed in
/usr/lib/python3/dist-packages/ifcopenshell/
Related
- Website: ifcopenshell.org
- Code repository: IfcOpenShell/IfcOpenShell
- Academy with examples and articles: academy.ifcopenshell.org
- OSArch community with resources for open source architecture: wiki.OSArch.org
- Compiling IfcOpenShell for MacOS; a guide that describes the general process. It may not be needed any more as IfcOpenShell is now distributed together with FreeCAD thanks to Conda.
- What pages link to this page.
- Elements: Wall, Structure, Curtain Wall, Window, Roof, Space, Stairs, Equipment, Frame, Fence, Truss, Profile, Pipe, Pipe Connector
- Reinforcements: Straight Rebar, U-Shape Rebar, L-Shape Rebar, Stirrup, Bent-Shape Rebar, Helical Rebar, Column Reinforcement, Beam Reinforcement, Slab Reinforcement, Footing Reinforcement, Custom Rebar
- Panels: Panel, Panel Cut, Panel Sheet, Nest
- Materials: Material, Multi-Material
- Organization: Building Part, Project, Site, Building, Level, External reference, Section Plane, Schedule
- Axes: Axis, Axes system, Grid
- Modification: Cut with plane, Add component, Remove component, Survey
- Utilities: Component, Clone component, Split Mesh, Mesh to Shape, Select non-manifold meshes, Remove Shape from Arch, Close Holes, Merge Walls, Check, Toggle IFC Brep flag, 3 Views from mesh, Create IFC spreadsheet, Toggle Subcomponents
- Additional: Preferences, Import Export Preferences (IFC, DAE, OBJ, JSON, 3DS, SHP), IfcOpenShell, IfcPlusPlus, Arch API
- Materials: Solid, Fluid, Nonlinear mechanical, Reinforced (concrete); Material editor
- Element geometry: Beam (1D), Beam rotation (1D), Shell (2D), Fluid flow (1D)
Constraints
- Electromagnetic: Electrostatic potential, Current density, Magnetization
- Geometrical: Plane rotation, Section print, Transform
- Mechanical: Fixed, Displacement, Contact, Tie, Spring, Force, Pressure, Centrif, Self weight
- Thermal: Initial temperature, Heat flux, Temperature, Body heat source
- Overwrite Constants: Constant vacuum permittivity
- Solve: CalculiX Standard, Elmer, Mystran, Z88; Equations: Deformation, Elasticity, Electrostatic, Electricforce, Magnetodynamic, Magnetodynamic 2D, Flow, Flux, Heat; Solver: Solver control, Solver run
- Results: Purge, Show; Postprocessing: Apply changes, Pipeline from result, Warp filter, Scalar clip filter, Function cut filter, Region clip filter, Contours filter, Line clip filter, Stress linearization plot, Data at point clip filter, Filter function plane, Filter function sphere, Filter function cylinder, Filter function box
- Additional: Preferences; FEM Install, FEM Mesh, FEM Solver, FEM CalculiX, FEM Concrete; FEM Element Types
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub