2011-05-08 11:04:32 +00:00
|
|
|
IfcOpenShell
|
|
|
|
|
============
|
2016-02-21 16:52:00 +02:00
|
|
|
IfcOpenShell is an open source ([LGPL]) software library for working with the Industry Foundation Classes ([IFC])
|
2019-06-14 10:00:42 +02:00
|
|
|
file format. Currently supported IFC releases are [IFC2x3 TC1] and [IFC4 Add2 TC1].
|
2016-02-21 16:52:00 +02:00
|
|
|
|
2016-02-20 00:43:35 +02:00
|
|
|
For more information, see
|
|
|
|
|
* [http://ifcopenshell.org](http://ifcopenshell.org)
|
|
|
|
|
* [http://academy.ifcopenshell.org](http://academy.ifcopenshell.org)
|
2015-08-10 11:38:43 +02:00
|
|
|
|
2016-08-09 14:12:12 +02:00
|
|
|
[](https://api.travis-ci.org/IfcOpenShell/IfcOpenShell)
|
|
|
|
|
|
2015-10-28 21:21:23 +02:00
|
|
|
Prerequisites
|
2016-02-20 00:43:35 +02:00
|
|
|
-------------
|
2016-02-19 23:02:09 +02:00
|
|
|
* Git
|
|
|
|
|
* CMake (2.6 or newer)
|
2017-03-28 22:54:06 +03:00
|
|
|
* Windows: [Visual Studio] 2008 or newer with C++ toolset (or [Visual C++ Build Tools]) or [MSYS2] + MinGW
|
2016-06-17 23:30:33 +03:00
|
|
|
* *nix: GCC 4.7 or newer, or Clang (any version)
|
2015-10-28 21:21:23 +02:00
|
|
|
|
2015-08-10 11:38:43 +02:00
|
|
|
Dependencies
|
2016-02-20 00:43:35 +02:00
|
|
|
-------------
|
2015-08-10 11:38:43 +02:00
|
|
|
* [Boost](http://www.boost.org/)
|
2017-02-24 16:46:14 +02:00
|
|
|
* [Open Cascade](http://opencascade.org) - *optional*, but required for building IfcGeom
|
|
|
|
|
([official](http://www.opencascade.org/getocc/download/loadocc/), "OCCT", or [community edition](https://github.com/tpaviot/oce), "OCE")
|
2015-08-10 11:38:43 +02:00
|
|
|
For converting IFC representation items into BRep solids and tesselated meshes
|
2016-02-05 14:48:51 +02:00
|
|
|
* [OpenCOLLADA](https://github.com/khronosGroup/OpenCOLLADA/) - *optional*
|
2015-08-10 11:38:43 +02:00
|
|
|
For IfcConvert to be able to write tessellated Collada (.dae) files
|
2016-02-21 16:52:00 +02:00
|
|
|
* [SWIG](http://www.swig.org/) and [Python](https://www.python.org/) - *optional*
|
2015-08-10 11:38:43 +02:00
|
|
|
For building the IfcOpenShell Python interface and the Blender add-on
|
2016-02-21 16:52:00 +02:00
|
|
|
* [3ds Max SDK](http://www.autodesk.com/products/3ds-max/free-trial) - *optional*
|
2016-02-19 22:53:09 +02:00
|
|
|
For building the 3ds Max plug-in.
|
|
|
|
|
All recent versions of 3ds Max (2014 and newer) are 64-bit only, so a 64-bit installation is assumed.
|
2011-05-08 11:04:32 +00:00
|
|
|
|
2016-02-20 00:43:35 +02:00
|
|
|
Building IfcOpenShell
|
|
|
|
|
---------------------
|
2016-12-30 15:57:13 +02:00
|
|
|
|
|
|
|
|
**Note:** The path where the source code is cloned to can contain spaces but non-ASCII characters are very likely to cause problems with the build.
|
|
|
|
|
|
2016-02-20 00:43:35 +02:00
|
|
|
### Compiling on Windows
|
2015-10-28 21:21:23 +02:00
|
|
|
The preferred way to fetch and build this project's dependencies is to use the build scripts
|
2016-07-15 06:49:32 +03:00
|
|
|
in win/ folder. **See [win/readme.md] for more information**.
|
|
|
|
|
|
2016-08-06 11:45:29 +03:00
|
|
|
#### Using Visual Studio
|
2016-07-15 06:49:32 +03:00
|
|
|
Instructions in a nutshell (**assuming Visual Studio 2015 x64 environment variables set**):
|
2015-11-21 13:15:31 +02:00
|
|
|
|
2015-12-04 17:01:33 +02:00
|
|
|
> cd IfcOpenShell\win
|
|
|
|
|
> build-deps.cmd
|
2015-12-01 14:47:49 +02:00
|
|
|
> run-cmake.bat
|
2015-12-04 17:01:33 +02:00
|
|
|
|
2020-03-25 14:09:22 +01:00
|
|
|
NB: `build-deps.cmd` need to be ran from the directory containing it, i.e. the `./win` folder.
|
|
|
|
|
|
2015-12-04 17:01:33 +02:00
|
|
|
You can now open and build the solution file in Visual Studio:
|
|
|
|
|
|
2015-10-28 21:21:23 +02:00
|
|
|
> ..\build-vs2015-x64\IfcOpenShell.sln
|
2015-11-21 13:15:31 +02:00
|
|
|
|
2015-12-04 17:01:33 +02:00
|
|
|
As the scripts default to using the `RelWithDebInfo` configuration, and a freshly created solution by CMake defaults
|
|
|
|
|
to `Debug`, make sure to switch the used build configuration. Build the `INSTALL` project (right-click -> Project
|
|
|
|
|
Only) to deploy the headers and binaries into a single location if wanted/needed.
|
|
|
|
|
|
2016-12-30 15:57:13 +02:00
|
|
|
Alternatively, one can use the utility batch file(s) to build and install the project easily from the command-line
|
|
|
|
|
(installing a project will build it also, if required):
|
2017-02-24 16:46:14 +02:00
|
|
|
|
2016-06-17 23:30:33 +03:00
|
|
|
> install-ifcopenshell.bat
|
2011-05-08 11:04:32 +00:00
|
|
|
|
2016-08-06 11:45:29 +03:00
|
|
|
#### Using MSYS2 + MinGW
|
2016-07-15 06:49:32 +03:00
|
|
|
|
|
|
|
|
Start the MSYS2 Shell and then:
|
|
|
|
|
|
|
|
|
|
$ cd IfcOpenShell/win
|
|
|
|
|
$ ./build-deps.sh
|
|
|
|
|
$ ./run-cmake.sh
|
|
|
|
|
$ ./install-ifcopenshell.sh
|
|
|
|
|
|
2016-08-06 11:45:29 +03:00
|
|
|
#### Using Bash on Ubuntu on Windows
|
|
|
|
|
|
2016-10-09 13:39:47 +03:00
|
|
|
Start Bash on Ubuntu on Windows and follow the instructions below. Compiling on Ubuntu 14.04.4 LTS using GCC 4.8.4
|
|
|
|
|
or Clang 3.5 has been confirmed to work.
|
2016-08-06 11:45:29 +03:00
|
|
|
|
2016-02-20 00:43:35 +02:00
|
|
|
### Compiling on *nix
|
2011-05-08 11:04:32 +00:00
|
|
|
|
2017-12-17 22:53:43 -05:00
|
|
|
The following instructions are for Ubuntu, modify as required for other operating systems. [nix/build-all.py] script
|
2016-08-06 11:45:29 +03:00
|
|
|
can be experimented with and studied for pointers for other operating systems, but note that this script is not currently
|
|
|
|
|
meant to be used for a typical IfcOpenShell workspace setup.
|
|
|
|
|
|
2018-03-16 16:36:36 +01:00
|
|
|
Note: where `make -j` is written, add a number roughly equal to the amount of CPU cores + 1.
|
|
|
|
|
|
2016-12-30 15:57:13 +02:00
|
|
|
**1)** Install most of the prerequisites and dependencies:
|
2016-08-06 11:45:29 +03:00
|
|
|
|
2019-05-10 11:59:00 +02:00
|
|
|
$ sudo apt-get install git cmake gcc g++ libboost-all-dev
|
2011-05-08 11:04:32 +00:00
|
|
|
|
2017-02-24 16:46:14 +02:00
|
|
|
**2a)** Either use an OCE package from your operating system's software repository
|
2015-03-22 20:06:04 +00:00
|
|
|
|
2016-08-06 11:45:29 +03:00
|
|
|
$ sudo apt-get install liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev
|
|
|
|
|
|
2017-02-24 16:46:14 +02:00
|
|
|
**2b)** or (if not available, or the latest code is wanted) compile OCE yourself (note that the build takes a long time):
|
2016-08-06 11:45:29 +03:00
|
|
|
|
|
|
|
|
$ sudo apt-get install libftgl-dev libtbb2 libtbb-dev libgl1-mesa-dev libfreetype6-dev
|
2015-03-22 20:06:04 +00:00
|
|
|
$ git clone https://github.com/tpaviot/oce.git
|
|
|
|
|
$ cd oce
|
|
|
|
|
$ mkdir build && cd build
|
|
|
|
|
$ cmake ..
|
2016-08-22 12:45:37 +03:00
|
|
|
$ make -j
|
2016-08-06 11:45:29 +03:00
|
|
|
$ sudo make install
|
|
|
|
|
|
2017-02-24 16:46:14 +02:00
|
|
|
**2c)** or obtain and compile OCCT from http://www.opencascade.org/getocc/download/loadocc/
|
|
|
|
|
|
2016-12-30 15:57:13 +02:00
|
|
|
**3)** For building IfcConvert with COLLADA (.dae) support (on by default), OpenCOLLADA is needed:
|
2016-08-06 11:45:29 +03:00
|
|
|
|
2018-03-16 16:36:36 +01:00
|
|
|
$ sudo apt-get install libpcre3-dev libxml2-dev
|
2016-08-06 11:45:29 +03:00
|
|
|
$ git clone https://github.com/KhronosGroup/OpenCOLLADA.git
|
|
|
|
|
$ cd OpenCOLLADA
|
|
|
|
|
Using a known good revision, but HEAD should work too:
|
|
|
|
|
$ git checkout 064a60b65c2c31b94f013820856bc84fb1937cc6
|
|
|
|
|
$ mkdir build && cd build
|
|
|
|
|
$ cmake ..
|
2016-08-22 12:45:37 +03:00
|
|
|
$ make -j
|
2016-08-06 11:45:29 +03:00
|
|
|
$ sudo make install
|
|
|
|
|
|
2016-12-30 15:57:13 +02:00
|
|
|
**4)** For building the IfcPython wrapper (on by default), SWIG and Python development are needed, if not already available:
|
2016-08-06 11:45:29 +03:00
|
|
|
|
|
|
|
|
$ sudo apt-get install python-all-dev swig
|
2015-03-22 20:06:04 +00:00
|
|
|
|
2016-12-30 15:57:13 +02:00
|
|
|
**5)** To build IfcOpenShell please take the following steps. Alternatively use environment variables for setting the
|
2016-08-22 12:45:37 +03:00
|
|
|
dependencies' paths. `OCC_INCLUDE_DIR` might be needed to set also. `OPENCOLLADA_INCLUDE_DIR` and `OPENCOLLADA_LIBRARY_DIR`
|
|
|
|
|
(and potentially `PCRE_LIBRARY_DIR`) are needed if building with COLLADA support. (`-DCOLLADA_SUPPORT=0` disables it).
|
2015-03-22 20:06:04 +00:00
|
|
|
|
2016-08-06 11:45:29 +03:00
|
|
|
$ cd /path/to/IfcOpenShell
|
2016-08-22 12:45:37 +03:00
|
|
|
$ mkdir build && cd build
|
|
|
|
|
$ cmake ../cmake -DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/ \
|
|
|
|
|
-DOPENCOLLADA_INCLUDE_DIR="/usr/local/include/opencollada" \
|
|
|
|
|
-DOPENCOLLADA_LIBRARY_DIR="/usr/local/lib/opencollada" \
|
|
|
|
|
-DPCRE_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/
|
|
|
|
|
$ make -j
|
2011-05-08 11:04:32 +00:00
|
|
|
|
2016-01-19 16:43:42 +02:00
|
|
|
If all worked out correctly you can now use IfcOpenShell. See the examples below.
|
|
|
|
|
|
2016-12-30 15:57:13 +02:00
|
|
|
**6)** Install the project if wanted:
|
2016-08-06 11:45:29 +03:00
|
|
|
|
|
|
|
|
$ sudo make install
|
|
|
|
|
|
2018-05-16 23:05:07 -04:00
|
|
|
Installing IfcOpenShell with Conda
|
|
|
|
|
----------------------------------
|
|
|
|
|
Another option for building and installing IfcOpenShell is to use the popular
|
|
|
|
|
[Anaconda Python Distribution](https://www.anaconda.com/download).
|
|
|
|
|
The requirements are spread across a number of channels.
|
|
|
|
|
You can add these channels to your configuration, or specify them all on the command line:
|
|
|
|
|
|
|
|
|
|
$ conda install -c conda-forge -c oce -c dlr-sc -c ifcopenshell ifcopenshell
|
|
|
|
|
|
2016-01-19 16:43:42 +02:00
|
|
|
Usage examples
|
2016-02-20 00:43:35 +02:00
|
|
|
--------------
|
2015-03-22 20:06:04 +00:00
|
|
|
|
2015-08-10 11:38:43 +02:00
|
|
|
**Invoking IfcConvert from the command line**
|
|
|
|
|
|
2015-03-22 20:06:04 +00:00
|
|
|
$ wget ftp://ftp.dds.no/pub/ifc/Munkerud/Munkerud_hus6_BE.zip
|
|
|
|
|
$ unzip Munkerud_hus6_BE.zip
|
|
|
|
|
$ ./IfcConvert Munkerud_hus6_BE.ifc
|
|
|
|
|
$ less Munkerud_hus6_BE.obj
|
|
|
|
|
|
2015-08-10 11:38:43 +02:00
|
|
|
**Using the IfcOpenShell Python interface**
|
|
|
|
|
|
2020-07-20 21:01:06 +03:00
|
|
|
$ wget -O duplex.zip https://portal.nibs.org/files/wl/?id=4DsTgHFQAcOXzFetxbpRCECPbbfUqpgo
|
2015-08-10 11:38:43 +02:00
|
|
|
$ unzip duplex.zip
|
2015-03-22 20:06:04 +00:00
|
|
|
$ python
|
|
|
|
|
>>> import ifcopenshell
|
|
|
|
|
>>> f = ifcopenshell.open("Duplex_A_20110907_optimized.ifc")
|
2015-08-10 11:38:43 +02:00
|
|
|
>>>
|
|
|
|
|
>>> # Accessing entity instances by type:
|
2015-03-22 20:06:04 +00:00
|
|
|
>>> f.by_type("ifcwall")[:2]
|
|
|
|
|
[#91=IfcWallStandardCase('2O2Fr$t4X7Zf8NOew3FL9r',#1,'Basic Wall:Interior - Partition (92mm Stud):144586',$,'Basic Wall:Interior - Partition (92mm Stud):128360',#5198,#18806,'144586'), #92=IfcWallStandardCase('2O2Fr$t4X7Zf8NOew3FLIE',#1,'Basic Wall:Interior - Partition (92mm Stud):143921',$,'Basic Wall:Interior - Partition (92mm Stud):128360',#5206,#18805,'143921')]
|
|
|
|
|
>>> wall = _[0]
|
|
|
|
|
>>> len(wall) # number of EXPRESS attributes
|
|
|
|
|
8
|
2015-08-10 11:38:43 +02:00
|
|
|
>>>
|
|
|
|
|
>>> # Accessing EXPRESS attributes by name:
|
|
|
|
|
>>> wall.GlobalId
|
2015-03-22 20:06:04 +00:00
|
|
|
'2O2Fr$t4X7Zf8NOew3FL9r'
|
|
|
|
|
>>> wall.Name = "My wall"
|
|
|
|
|
>>> wall.NonExistingAttr
|
|
|
|
|
Traceback (most recent call last):
|
|
|
|
|
File "<stdin>", line 1, in <module>
|
|
|
|
|
File ".\ifcopenshell.py", line 14, in __getattr__
|
|
|
|
|
except: raise AttributeError("entity instance of type '%s' has no attribute'%s'"%(self.wrapped_data.is_a(), name)) from None
|
|
|
|
|
AttributeError: entity instance of type 'IfcWallStandardCase' has no attribute 'NonExistingAttr'
|
|
|
|
|
>>> wall.GlobalId = 3
|
|
|
|
|
Traceback (most recent call last):
|
|
|
|
|
File "<stdin>", line 1, in <module>
|
|
|
|
|
File ".\ifcopenshell.py", line 26, in __setattr__
|
|
|
|
|
self[self.wrapped_data.get_argument_index(key)] = value
|
|
|
|
|
File ".\ifcopenshell.py", line 30, in __setitem__
|
|
|
|
|
self.wrapped_data.set_argument(idx, entity_instance.map_value(value))
|
|
|
|
|
File ".\ifc_wrapper.py", line 118, in <lambda>
|
|
|
|
|
set_argument = lambda self,x,y: self._set_argument(x) if y is None else self
|
|
|
|
|
._set_argument(x,y)
|
|
|
|
|
File ".\ifc_wrapper.py", line 114, in _set_argument
|
|
|
|
|
def _set_argument(self, *args): return _ifc_wrapper.entity_instance__set_argument(self, *args)
|
|
|
|
|
RuntimeError: INT is not a valid type for 'GlobalId'
|
2015-08-10 11:38:43 +02:00
|
|
|
>>> # Creating new entity instances
|
2015-03-22 20:06:04 +00:00
|
|
|
>>> f.createIfcCartesianPoint(Coordinates=(1.0,1.5,2.0))
|
|
|
|
|
#27530=IfcCartesianPoint((1.,1.5,2.))
|
2015-08-10 11:38:43 +02:00
|
|
|
>>>
|
|
|
|
|
>>> # Working with GlobalId attributes:
|
2015-03-22 20:06:04 +00:00
|
|
|
>>> import uuid
|
|
|
|
|
>>> ifcopenshell.guid.compress(uuid.uuid1().hex)
|
|
|
|
|
'3x4C8Q_6qHuv$P$FYkANRX'
|
|
|
|
|
>>> new_guid = _
|
|
|
|
|
>>> owner_hist = f.by_type("IfcOwnerHistory")[0]
|
|
|
|
|
>>> new_wall = f.createIfcWallStandardCase(new_guid, owner_hist, None, None, Tag='my_tag')
|
|
|
|
|
>>> new_wall.ObjectType = ''
|
|
|
|
|
>>> new_wall.ObjectPlacement = new_wall.Representation = None
|
2015-08-10 11:38:43 +02:00
|
|
|
>>>
|
|
|
|
|
>>> # Accessing entity instances by instance id or GlobalId:
|
2015-03-22 20:06:04 +00:00
|
|
|
>>> f[92]
|
|
|
|
|
#92=IfcWallStandardCase('2O2Fr$t4X7Zf8NOew3FLIE',#1,'Basic Wall:Interior - Partition (92mm Stud):143921',$,'Basic Wall:Interior - Partition (92mm Stud):128360',#5206,#18805,'143921')
|
|
|
|
|
>>> f['2O2Fr$t4X7Zf8NOew3FLIE']
|
|
|
|
|
#92=IfcWallStandardCase('2O2Fr$t4X7Zf8NOew3FLIE',#1,'Basic Wall:Interior - Partition (92mm Stud):143921',$,'Basic Wall:Interior - Partition (92mm Stud):128360',#5206,#18805,'143921')
|
2015-08-10 11:38:43 +02:00
|
|
|
>>>
|
|
|
|
|
>>> # Writing IFC-SPF files to disk:
|
2015-03-22 20:06:04 +00:00
|
|
|
>>> f.write("out.ifc")
|
2015-11-11 17:41:38 +02:00
|
|
|
|
2016-02-20 00:43:35 +02:00
|
|
|
[LGPL]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/COPYING "LGPL"
|
2019-12-16 01:32:53 +01:00
|
|
|
[IFC]: https://technical.buildingsmart.org/standards/ifc/ "IFC"
|
|
|
|
|
[IFC2x3 TC1]: https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ "IFC2x3 TC1"
|
|
|
|
|
[IFC4 Add2 TC1]: https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/HTML/ "IFC4 Add2 TC1"
|
2016-08-06 11:45:29 +03:00
|
|
|
[Visual Studio]: https://www.visualstudio.com/ "Visual Studio"
|
|
|
|
|
[Visual C++ Build Tools]: http://landinghub.visualstudio.com/visual-cpp-build-tools "Visual C++ Build Tools"
|
2016-07-15 06:49:32 +03:00
|
|
|
[MSYS2]: https://msys2.github.io/ "MSYS2"
|
2016-08-06 11:45:29 +03:00
|
|
|
[win/readme.md]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/win/readme.md "win/readme.md"
|
2017-12-17 23:06:39 -05:00
|
|
|
[nix/build-all.py]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/nix/build-all.py "nix/build-all.py"
|