xBimTeam / XbimExchange

XbimExchange contains several COBie schemas and serialisation functions as well as the Model Validation library adopted by theNBS digital toolkit.
https://xbimteam.github.io/
Other
46 stars 42 forks source link

Ifc to Json Convert issue #60

Open Abhicode5 opened 3 years ago

Abhicode5 commented 3 years ago

@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.Dictionary`2.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()