Convert IFC 2 Json is a .net Core Library based on GeometryGymIFC.
Requirements: The .NET 6.0 must be installed.
Run commande
./ConvertIfc2Json sourcefile.ifc
Run commande with output name
./ConvertIfc2Json sourcefile.ifc output.json
If you don't specify an output name, the name of the Json result file will be "sourcefile.ifc.json".
--indented
: if you add this parameter the json will be Formated.
--full
: if you add this parameter all the IFC will be returned in Json format.
--version
: display version number
Here is the code structure to extract the IFC elements according to the building hierarchy :
IfcProject (Project)
|
|-IfcSite (Site)
|
|-IfcBuilding (Building)
|
|-IfcBuildingStorey (Building level)
|
|-IfcSpace (Space / room)
|
|- IfcElement
build.sh
(for MacOS + Linux)The packages are installed via the Nuget package manager:
The library is the most reliable in the IFC transformation world (also used in Revit, Rhino, etc.)
We compile the library for the .NET 6.0 environment. Originally, this is only for the .NET (Windows) environment.
Source code : github.com/GeometryGym/GeometryGymIFC
Recommendation: use Visual Studio 2019+
Hack the file (remove the windows feature) : /IFC/IFC O.cs
Replace in the file > GeometryGym.Ifc.IfcOrganization (L819).
replace that :
#if (!NETSTANDARD2_0)
string name = ((string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization", "")).Replace("'", "");
if (!string.IsNullOrEmpty(name) && string.Compare(name, "Microsoft", true) != 0 && string.Compare(name, "HP Inc.",true) != 0)
return name;
#endif
by this :
#if (!NETSTANDARD2_0)
//string name = ((string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization", "")).Replace("'", "");
string name = null;
if (!string.IsNullOrEmpty(name) && string.Compare(name, "Microsoft", true) != 0 && string.Compare(name, "HP Inc.",true) != 0)
return name;
#endif
Change Framework : .NET 6.0
Update Nuget package Newtonsoft.Json
Create a file at the root of the folder (update version number) : AssemblyInfo.cs
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("GeometryGymIFC")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.1.09.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("0.1.09.0")]
[assembly: System.Reflection.AssemblyProductAttribute("GeometryGymIFC")]
[assembly: System.Reflection.AssemblyTitleAttribute("GeometryGymIFC")]
[assembly: System.Reflection.AssemblyVersionAttribute("0.1.09.0")]
Compile (Any CPU)
Copie file in the Ifc2json folder :
bin\Release\net6.0\GeometryGymIFCcore.dll
linux
+ macos
+ win