xBimTeam / XbimEssentials

A .NET library to work with data in the IFC format. This is the core component of the Xbim Toolkit
https://xbimteam.github.io/
Other
506 stars 174 forks source link

IFC to CityJSON and CITYGML #388

Open dikyridhlo opened 3 years ago

dikyridhlo commented 3 years ago

I have an IFC file contains 3D building, I want to store this file to 3DcityDB, which is needed in CITYJSON or CITYGML format. Can I convert the IFC file to CITYJSON or CITYGML format using XBIM?

I use XbimExchanger to convert JSON and XML but the output was different with CITYJSON or CITYGML format.

this is my code from Pass1192

using (var m = IfcStore.Open("SampleHouse.ifc"))
            {
                var facilities = new List<Facility>();
                var ifcToCoBieLiteUkExchanger = new IfcToCOBieLiteUkExchanger(m, facilities);
                facilities = ifcToCoBieLiteUkExchanger.Convert();

                var facilityType = facilities.FirstOrDefault();
                if (facilityType == null)
                    return;
                //write the cobie data in json format
                facilityType.WriteJson("Cobie.json", true);
                //write the cobie data in xml format
                facilityType.WriteXml("Cobie.xml", true);
                //write the cobie data in spreadsheet format                 
                string errMsg;
                facilityType.WriteCobie("Cobie.xls", out errMsg);
}
martin1cerny commented 3 years ago

Hi @dikyridhlo , COBie is very different from CityGML, so this code is probably useless for you. We haven't implemented conversion to CityGML in the xbim Toolkit, but you can use it as a solid ground to develop one. If you wanted to contribute it to the project, it would certainly be appreciated.

You can use XbimEssentials libraries to read the complete IFC model. But you will need to implement the transformation to CityGML/JSON yourself. You can certainly use some code generation tools to get a working implementation of the CityGML schema (if you don't have or find one). The core part is then obviously the conceptual transformation between the two schemas.

Geometry is likely to be tricky. If you go with the least common denominator, you can use XbimGeometry to convert all the geometries to triangulated mesh which is most portable, but also uses most resources.

Do you want to share more about your project?