I would like to convert an IFC file to COBie using python.
Currently I'm using IfcOpenShell, yet I can't figure out a way to convert the file. Is it possible?
Any advice would be great!
By converting "IFC to COBie", I assume you mean converting the IFC representation of COBie data to the Spreadsheet-based representation of COBie data. This is an important distinction, as IFC is COBie. The spreadsheet is merely a simplified representation of it.
Use the IfcCOBie utility that is part of IfcOpenShell. https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0/src/ifccobie
There is a UI for it in the BlenderBIM Add-on, with code demonstrating how to run it: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.6.0/src/blenderbim/blenderbim/bim/module/cobie/operator.py#L70-L123
However, there are caveats. The spreadsheet mappings in COBie were specified in a rather ambiguous way. Vendors who vouch for providing COBie data in IFC are being dishonest - the fact is that nobody is delivering their COBie data correctly in IFC. Despite that, the IfcCOBie tool is idealistic and assumes it is delivered correctly. With this mismatch, the only way for the tool to be 100% successful is for you to clean up your IFC beforehand.
Note that there is also a new FM Handover MVD in draft form, set to supersede COBie. I have half written code for this in the IfcFM module. https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0/src/ifcfm - so far, I prefer it to COBie.
Thank you, @Moult. I also appreciate the honesty about COBie use.
Additionally, I understand that COBie is an MVD and, therefore, an IFC (smaller ;P ).
I apologize if I was not clear enough. What I am looking for is simpler. I am looking for a way to apply an MVD (for instance, COBie) to an IFC file.
In a nutshell:
I have an IFC file as input, and I would like to use IfcOpenShell (if possible) to apply the COBie MVD (it would be great if I could use any MVD) and reduce the file. The output should be an IFC, just smaller. Then I would "convert it" to a COBie spreadsheet, but not necessarily!
Do you have any advice on how to achieve this?
Thank you once again :)
@FDinis alas, in theory applying an "MVD" to a rich IFC to receive a smaller IFC is possible, but in practice there are so many problems with the bespoke mvdXML dialect that this is quite a complex task. MVDs are dying a slow death.
Also, in practice, most IFC parsers are fully capable of partial parsing. For example, lets say I include costing and scheduling data in my IFC. This is outside the scope of the IFC4 Reference View MVD. However, that won't stop me from loading my IFC into Revit - Revit will happily consume whatever it needs and ignore the rest. Therefore, so long as your IFC contains a superset of the MVD you're interested in (i.e. more data than you're asked for), you're good to go - don't worry about culling it down.