FreeCAD and IFC: sticking to standards
After my last post
about IFC support in FreeCAD, I worked a bit further in order to make the test house
behave better when imported into other IFC-capable applications. This is basically the first steps of FreeCAD into the big boys playground. I already leaned a few tricks on the way, that are worth sharing here.
The first thing to know, is that the IFC format is complex, and there are usually many ways to achieve something, and things can become very, very complicated. So I started with the easiest path (the idea is to go the more complex ways later on), which is exporting all the geometry as faceted objects. This is obviousy not excellent, since the objects are reduced to a bunch of faces, and become very hard or impossible to edit. But, this method has the merit to just export anything, without errors (as long as there are no curves, that's for later).
The first test I did was also reimport the IFC test house in freecad. So far so good, all the objects are recreated correctly. Only problem, as stated above, they became dumb shapes, and lost their parametric behaviour.
A second step I did then, is to use the most basic and most used modeling mechanism of IFC: extrusions. Instead of defining an object by its faces, you define a base loop (polyline), and an extrusion vector (direction and length). Several FreeCAD objects are now exported that way when you do an IFC export. At the moment, though, this mechanism is only used in "clean" cases (objects that have no addition or no subtraction, and where the extrusion is in the Z direction). Of course, later on, we need to dissociate these additions and subtractions, so this extrusion mechanism will catch more and more cases.
A second application that is now my favorite test platform, is ifc++
. It is an opensource, multiplatform IFC library and viewer, and it is also, thanks to Bernd
, the first good, native IFC viewer we have on the Linux platform.
, FreeCAD's IFC engine, which is really rock-solid and can swallow all kinds of wierdly-formatted IFC files, Ifc++ is the second best IFC engine I used in these tests. It sometimes displays some errors, but rarely refuses to render something and is pretty tolerant of bad formatting. It is interesting to notice that, while commercial IFC vendors try to stick as most as possible to the standards, and will just yell at you when you come with your not-totally-up-to-the-standards IFC file, these two open-source apps are way more tolerant, and try as best as they can to handle your errors.
After that I tried to import our test house in two of the big players, Revit and ArchiCAD. Results were not very good at first, but this made me discover several interesting things:
- When you define a polyline to be used as the base profile of an extrusion, this polyline must lie on the XY plane. It is the extruded object that you then move to its correct position.Windows can only be children of walls if they are children of an opening object which is in turn child of the wall. No way to make a window a child of a wall without the opening object. So for now, they are exported as "stand-alone" windows, which seems to satisfy everybody so far...
- Windows, apparenlty, cannot be children of structural objects. Only walls...
- The primary way to define a relationship between two architectural objects, in IFC, is to make them children of the same "gathering" object, such as a storey. This is enough for most software.
- One object having different representations is interpreted differently depending on the software, but this is not made to add several shapes to an object, although it seems to work (Revit complains).
After a lot of corrections, our test house now opens correctly in Revit and ArchiCAD:
The roadmap now is to add the following features:
- Fix extrusion orientations (currently only vertical extrusions (along Z axis) work
- Extrusions of circles (partially done already)
- Extrusions of ellipses
- Extrusions of complex polylines (with arcs inside)
- Breps solids with curved surfaces
- Subtractions and openings
- Boolean additionsAxes, and additional properties such as heights and widths
After that I think we can say we'll have decent IFC export from FreeCAD, and probably as good as many others...