Closed lufimoreira closed 5 years ago
Might be worth looking at how we do it in https://github.com/xBimTeam/XbimExchange/blob/261d31c95c736158a7289a3c9e0e5762ad464695/Xbim.Exchange/Program.cs#L303
@andyward , @martin1cerny i have the wexbim file , now i want the json file to get the complete model data, i am getting the following error
using Microsoft.Extensions.Logging;
using Serilog;
using System.IO;
using Xbim.Common;
using System;
using Xbim.Ifc;
using Xbim.ModelGeometry.Scene;
using System.Diagnostics;
using Xbim.COBieLite;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Xbim.Common.Step21;
using Xbim.CobieLiteUk;
using Xbim.CobieLiteUk.FilterHelper;
using Xbim.IO;
using XbimExchanger.COBieLiteUkToIfc;
using XbimExchanger.IfcHelpers;
namespace CreateWexBIM
{
class Program
{
public static void Main()
{
using (var model = IfcStore.Open("test.ifc"))
{
var cobieFileName = "semantics.json";
using (var cobieFile = new FileStream(cobieFileName, FileMode.Create))
{
var helper = new CoBieLiteHelper(model, "UniClass");
var facility = helper.GetFacilities().FirstOrDefault();
if (facility != null)
{
using (var writer = new StreamWriter(cobieFile))
{
CoBieLiteHelper.WriteJson(writer, facility);
writer.Close();
}
}
}
model.Close();
}
}
}
}
Error
Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Xbim.COBieLite.CoBieLiteHelper.GetClassification(IIfcDefinitionSelect classifiedObject) at Xbim.COBieLite.SpaceType..ctor(IIfcSpace ifcSpace, CoBieLiteHelper helper) at Xbim.COBieLite.FloorType..ctor(IIfcBuildingStorey ifcBuildingStorey, CoBieLiteHelper helper) at Xbim.COBieLite.FacilityType..ctor(IIfcBuilding ifcBuilding, CoBieLiteHelper helper) at Xbim.COBieLite.CoBieLiteHelper.<GetFacilities>d__81.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 source)
at CreateWexBIM.Program.Main()
I'm sorry, but IFC to COBieLite JSON is not in the scope of our current work. Feel free to fork the project on GitHub, debug, fix and create a pull request. All contributions are welcome.
ok. @martin1cerny . But how did you create your (xbimwebui ) LakesideRestaurant.json file? How can i approach the problem . could you please guide me ? All i want is a json file that contains model information (by parsing ifc or any other approach ) so that in xbimWebui i can use this file to show model info and properties.
It was created with the same code as yours. There seem to be an issue with classification reference in your data.
@martin1cerny
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Xbim.COBieLite.CoBieLiteHelper.GetCreatingApplication(IIfcRoot ifcRootObject)
at Xbim.COBieLite.FacilityType..ctor(IIfcBuilding ifcBuilding, CoBieLiteHelper helper)
at Xbim.COBieLite.CoBieLiteHelper.<GetFacilities>d__81.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at CreateWexBIM.Program.Main()
I tried with another ifc file. how can we handle the exception?
All IfcRoot objects had an IfcOwnerHistory defined as a mandatory field in IFC2x3. This has changed in IFC4 but our code might still expect it to be there and not checking for null value. Debug and try. I'm sorry, but IFC to COBieLite JSON is not in the scope of our current work. Feel free to fork the project on GitHub, debug, fix and create a pull request. All contributions are welcome.
@martin1cerny got your point. So is it possible that i manually change some properties of ifc4 file setting null value to any random value and then do conversion?
Yes
Hi, I am able to convert my IFC files to wexbim, however, I also need the JSON. I've followed this post: xBimTeam/XbimWebUI#3 and I realised that XBimModel is outdated. How do I do this with IfcStore?