Thursday, July 28, 2011

IFC EXPRESS schema definitions

As you might have heard, IFC files are based on a schema that defines the things that may exist inside an IFC file and how they relate to each other. In order to get up and running quickly, till now IfcOpenShell used a more or less schema-less approach, but from this joyous day on will parse IFC files using the schema definitions provided by buildingSMART. This means we now have the entire inheritance graph at our disposal, which surely might come in handy someday. In plain English this would translate to knowing that an IfcWallStandardCase is a subtype of an IfcWall, which is a special kind of building element, etc.

To be able to generate the required C++ code from the Express schema, I have written some code in Python using Parser combinators, provided by the funcparserlib Python library. Combinatory parsing is an elegant method that combines elementary parsing routines into the complex framework required to parse these kind of files. Unfortunately the code ended up to be less elegant than what was hoped for, but it works for now. Although rules, functions and where clauses are discarded for now. Take a peek at the Python source over here: http://ifcopenshell.svn.sourceforge.net/viewvc/ifcopenshell/src/ifcexpressparser/IfcExpressParser.py?view=markup

Readers of this blog who feel shocked that adding 20.000 lines of generated C++ code to the project has added virtually no additional functionality might find consolation in the fact that it becomes easier now to add new functionality to IfcOpenShell. You go ahead and try for yourself if you don't believe me!

By the way, if you want to generate your own C++ code from the Express schema, you can grab your copy of the Industry Foundation Classes longform EXPRESS schema version 2x3 Technical Corrigendum 1, or IFC2x3_TC1.exp for short, at the buildingSMART tech site at: http://buildingsmart-tech.org/downloads/ifc/ifc2x3tc

9 comments:

  1. Kudos!

    Two years ago, I tried for two months writing a clean EXPRESS parser in python, but I gave up :-( I went on using JSDAI from LKSoft, with a jpython bridge, and it worked quite well (http://sourceforge.net/projects/pysdai/).

    It would be wonderful that you're able to provide an industrial quality Python EXPRESS parser.

    Regards,

    Thomas

    ReplyDelete
  2. Again, thanks for the link! Industrial quality is a very long way to go for the parser. Might you ever feel like it, it would be great if someone with more python experience could have a look.

    Kind regards,
    Thomas

    ReplyDelete
  3. Hi Thomas,
    I'm working on a IFC importer for FreeCAD ( http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Arch/ ) based on the work of this guy ( http://konstruct.nl/parsing-ifc-stepexpress-files-in-python-and-s ).. I must admit I didn't look too much at ifcopenshell yet because our problem is more in creating useful objects in freecad from ifc entities that importing ifc data itself... But it's time to have a better look!
    I'll post more feedback later
    Cheers
    Yorik

    ReplyDelete
  4. Hi Yorik,

    Thanks for your message. I actually know Marijn quite well, I'll talk to him and see if there's any chance whether we can combine our python parsing efforts (that won't be for a couple of weeks due to holidays et al).

    I understand that the TopoDS_Shapes and triangulated meshes are of very little use to you, since you are probably want to present the geometrical operations themselves to the user. I have some plans for representing the entities in a stack based manner with the sequentially applied operations applied to them, but nothing concrete. My uneducated guess would be that, if anything, the part of IfcOpenShell that could be of some use to you as a reference, are the functions that convert the IFC entities into the Open CASCADE shapes [ IfcGeomShapes.cpp IfcGeomWires.cpp IfcGeomFaces.cpp etc. ].

    Kind regards,
    Thomas

    ReplyDelete
  5. Yes, that's more or less that, I give you an example: Importing an Ifc wall, I don't even look at the shape, the most useful for me is retrieving other info, such as the "centerline" that generates the wall, the height, the other entities that make holes in it, the structures where the wall belong, etc, so I can build a parametric wall in freecad, that uses that info, and builds its shape itself.
    The cool work Marijn did is that all the contents of the ifc file get translated into a python structure, which is super easy to browse and retrieve what you need.

    ReplyDelete
  6. Hi Yorik,

    I understand. Regarding your example, the C++ IfcParse library of IfcOpenShell, would be perfectly able to interpret the Axis Representation of the wall and the inverse attributes, like ConnectedTo, -From and HasOpenings. But that's not that helpful if you're looking for a python solution.

    Kind regards,
    Thomas

    ReplyDelete
  7. Hello good man,

    i want to ask you is this addon available for lates Blender ?
    Is there a way that i can upgrade it to most recent Blender ?

    ReplyDelete
  8. Hi Nedzad,

    We are working at recompiling IfcOpenShell for Blender 2.65. If everything goes well, a new release should be ready within a couple of weeks, so keep an eye on the IfcOpenShell.org website.

    Kind regards,
    Thomas

    ReplyDelete