One of the strengths of the IfcOpenShell library is the vast amount of shape analysis and healing tools that Open Cascade provides. This allows for transforming, validating, generating and analysing geometry in IFC files, for example, to compute missing IfcProperty values, validate geometrical constraints, implement clash- and interference checking and the generation of new geometry.
pythonOCC exposes the rich set of functionality that Open Cascade provides to a Python environment, which allows for intuitive rapid prototyping. Since IfcOpenShell also provides a Python wrapper, the two of them can be easility tied together to create a development environment for working with geometry in IFC files in an interactive, quick, but also, very powerful way.
To demonstrate the possibilities, or rather, the first baby steps towards a more interesting and meaningful demonstration, I put together a quick example here: http://ifcopenshell.org/pythonOCC/example1/. The set of dependencies to get the system running is long, but it is worth it!
Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts
Friday, December 19, 2014
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
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
Subscribe to:
Posts (Atom)
