IfcOpenShell_PythonWrapper
IfcOpenShell_PythonWrapper copied to clipboard
Wrong topology and solids
Hi Thomas, here is a specific case we found the other day: https://dl.dropboxusercontent.com/u/7546976/slab.ifc
The above file contains an IfcFooting (#3142), which body representation is made of several Brep solids (#235). Apparently, as far as I can see, some faces of the breps seem to have wrong normals (which is visible when converting the ifc file to obj and opening it in blender).
As a result (probably), when creating the shape with IfcImport.create_shape(), the inner solids are lost, and the shape comes as a big compound of faces. This piece of code, run inside FreeCAD, shows you what happens:
import IfcImport,Part f=IfcImport.open("/home/yorik/slab.ifc") f <IfcImport.IfcFile; proxy of <Swig Object of type 'IfcParse::IfcFile *' at 0x7f44f430a780> > o=f.by_id(3142) o
3142=IfcFooting('0dFQTrJef12fHj9B6Va$DI',#4,' ',$,$,#233,#3129,$,.NOTDEFINED.)
b=IfcImport.create_shape(o) s=Part.Shape() s.importBrepFromString(b) s.ShapeType 'Compound' s.Solids [] s.Shells [] s.Faces [Face object at 0x758dfd0, ... , Face object at 0x75936a0]
Normally IfcOpenShell recreates those solids correctly. Do you think there could be a way to recover the solid information with such malformed objects? I'm not sure it's worth the effort, though. It might involve a lot of extra operations...
Anyway, I'd like to have your opinion on this... Cheers Yorik
Hi Yorik,
I think only the previous version of the python wrapper attempted to merge the faces into solids. Just added some code by which you can do the following:
b=IfcImport.create_shape(o, IfcImport.SEW_SHELLS)
Not sure if it works though. Haven't been able to check the result. So please let me know :)
Best, Thomas
Thanks for the fix! Unfortunately I just tested with the file above, there is no difference... But honestly that file seems a bit problematic, I wouldn't spend too much time on it, I'm pretty sure there is something wrong about it. Maybe just leave this issue open so we can investigate more..
Ah, even without this fix, this branch is already capable of recreating solids... I have several freecad examples here where multi-solids objects are successfully exported and reimported into freecad via IfcOpenShell.
Is it possible that this problem happens because of coincident vertices that would get merged together? I'll do some more testing.
Well, not so fast ;) just one thing I wanted to mention: IfcOpenShell does caching on the shapes it creates. So if you create brep_data for the same shape successively with different settings, you'll end up being returned the same data as the first run.
I really did check that with the SEW_SHELLS option at some point the shapes lived existed as solids rather than compounds.
Just found a possibility to export the slab from Allplan in a way FreeCAD is able to handle the Compound. The Check Geometry in FreeCAD says no error. If the ArchObject in Allplan is converted to a "stupid" solid it is still a set of faces but it is no longer invalid in FreeCAD ... It doesn't solve the issue but I thought it's worth to mention.
In FreeCAD
import IfcImport,Part f=IfcImport.open("/home/hugo/Desktop/slab_exported_as_solid.ifc") f <IfcImport.IfcFile; proxy of <Swig Object of type 'IfcParse::IfcFile *' at 0x7f9591a85c90> > o=f.by_id(1584) o #1584=IfcBuildingElementProxy('2NLijypHPBQu9qUuFwNJpk',#4,' ',$,$,#82,#1569,$,$) b=IfcImport.create_shape(o) s=Part.Shape() s.importBrepFromString(b) s.ShapeType 'Compound' s.Solids [] s.Shells [] s.Faces [ Face object at 0x6f01290 , ... , Face object at 0xd43fda0 ]
Download at: http://www.b75.ch/bim/slab_exported_as_solid.ifc