IFC-gen is an IFC code generator for IFC2X3 and IFC4. The code generator uses ANTLR to parse the Express.g4
grammar file and generate a parser. The parser is capable of reading the IFC object model as described in EXPRESS format in IFC4.exp
or IFC2X3.exp
. In addition, IFC-gen uses the STEP grammar described in STEP.g4
to generate a STEP parser whose generated files are output in the target language directory. The code generator is a dotnet core project containing an interface, ILanguageGenerator
, which is implemented by classes which generate code.
Source files for each target language can be found in the directory corresponding to the language's name. For example, the source code for the C# IFC library generator can be found in the /lang/csharp
folder. For per-language build instruction, please see the language folder's README
.
If you work in an architecture or engineering firm writing code, or a software startup that's trying to solve problems in AEC, where do you go to find a library that reads and writes building data in an industry-standard form? Maybe you've looked at the IFC schema and, like many before you, have decided that it's "too complex" or "too heavy" for your needs. Maybe you've even gone and built your own data model to describe building elements.
As more firms build their own data models to solve the same problem, we get further away from the vision of what IFC was supposed to be. By comparison, it would be as if every software company that makes a browser decided that they were going to create their own markup and styling languages such that the website you've designed to work in one, wouldn't work in any of the others. That's crazy. It seems to me that not speaking the same language is an impediment to technological progress in AEC.
IFC-gen was created to make generating IFC-compliant software libraries easy, and to ease the updating and testing of those libraries with new releases of the IFC specification. To achieve this goal, IFC-gen has code generation at its core. What do you want to build? A Python library? An Open API specification? A GraphQL schema? Creating a generator for any of these is as easy as providing a new implementation of ILanguageGenerator
.
If IFC-gen isn't exactly what you're looking for, there are a few other great IFC related projects that you might want to check out:
- https://github.com/hypar-io/elements
- http://bimserver.org
- http://ifcopenshell.org
- https://github.com/jmirtsch/GeometryGymIFC
- https://github.com/xBimTeam
IFC-gen supports the IFC2X3 and IFC4 schemas. These are represented by the IFC2X3
and IFC4
branches in this repository. If you are contributing to this repository, your change will need to be applied to both branches, unless it is a change that can only be logically applied to one branch.
Why didn't we just build support for various schemas into one branch? Differences in the schema often require differences in the grammar, which in turn generates different parsers, etc. For consumers of libraries generated by IFC-gen, this will mean different versions of libraries to parse IFC data from different schemas. This is not ideal, but our experience has shown that it is preferrable to having one library that is meant to support every version of the schema ever. Additionally, we can use git tools to do things like diff the schemas to see exactly what has changed:
git diff IFC2X3..IFC4 -- schemas/IFC.exp
- ANTLR grammar for IFC EXPRESS.
-
ExpressListener
to generate intermediate type data. - CI/CD integration with Travis.
- Generation in all supported languages of ALL types described by the schema.
- Common BDD test suite with test implementations in all supported languages.
- Package generation for all supported languages (i.e. Nuget package for IFC-dotnet).
- Minimum one local file storage back end and one db back end.
- Support for reading and writing STEP files per ISO 10303-21.
- ANTLR. ANTLR is used to generate parsers from a grammar. Follow the instructions on the ANTLR website to install ANTLR and create aliases to the ANTLR binaries.
- .NET. Currently, IFC-gen creates a C# executable,
IFC-gen.dll
, for generating IFC from the EXPRESS schema.
To generate the parsers:
make generate
To generate language code:
make <language>
make.bat
Check out issues marked help wanted.
Language generators implement the ILanguageGenerator
interface. You can find implementations of ILanguageGenerator
in /Generators
. To create your own language generator do the following:
- Place an implementation of
ILanguageGenerator
in/Generators
. - Extend the command line options parsing in
Program.cs
to support your target language. - Extend the makefile with a new task for the language.
Due to the size of the IFC schema, debugging the parser can be painful. I recommend creating a debug.exp
in the root directory that contains only the entities that you are trying to debug, then using make debug_parser
. This make step will generate the parser based on the debug schema, and will run IFC-gen
outputting tokens to the console for debugging.