Postby yorik » Sat Sep 29, 2018 2:41 pm
Basically almost all IFC export problems come down to this:
IFC geometry can be made of many different ways: extrusions of 2D profiles, booleans (subtractions, unions), or simply faceted brep objects (defined by a series of flat faces), or, most advanced (AFAIK only IfcOpenShell is capable todo that), NURBS-based brep objects (defined by a series of NURBS surfaces).
IfcOpenShell, in its latest versions, now has a "serializer" functionality, where you give it an OCC shape, any kind of shape, and it will produce an adequate IFC geometry: NURBS, faceted, or anything else. It is implemented in FreeCAD (there is an IFC preference option to enable), but it hasn't been tested extensively.
The thing is, for us, exporting as NURBS would be the safest. 100% guarantee that the IFC geometry is the same as in FreeCAD. If an object has only flat faces, faceted brep is also 100% guaranteed. Since each face is defined by a series of vertices, there is basically no room for error.
The problem is, other BIM applications are far less tolerant than FreeCAD. Revit particularly is extremely picky on what it can do with the contents of an IFC file. So, in FreeCAD, we try as much as possible to export geometry as something that Revit likes more, such as extrusions of a 2D profile. This has also the advantage that some of the modeling history (the 2D profile + the extrusion) is stored in the IFC file too, making it already much more parametric. However, that's where problems begin. The whole system of geometry positioning in IFC is very complex and error-prone, and even worse, not all applications interpret placements the same way. Same goes for unions, subtractions, or several objects that share a same geometry.
So usually, if you export something from FreeCAD and it's not correct in the IFC file, the number one culprit is the extrusion/placement. When exporting, in the report view you will be able to see how a particular object has been exported (extrusion, brep or reusing shared geometry)
A quick way to test (and solve), is to select the problematic object in FreeCAD, and Arch->Utils->Toggle Brep flag. This stores a value in the object's IfcAttributes property, that makes the IFC exporter force-export the object as a faceted brep. If the object didn't export correctly as an extrusion but does export correctly as brep, then we have our culprit. If the brep exported object works ok for you (depends on the application you'll import the IFC file to), this is a good workaround.
Of course we need to improve the extrusion export system. But we need to isolate cases that should be exported as extrusions and don't work correctly.
The case of "complex" sketches is complicated. Internally, an Arch wall built on such a complex sketch will build a wall on each wire found in the sketch, then union those wires. So the IFC exporter doesn't have a 2D profile to extrude. Maybe as a quick workaround we could force-export these walls as breps. But I am still not sure what would be a better solution...