private void MapSystems(IfcStore ifcStore, LibalIfcToCOBieLiteUkExchanger ifcToCoBieLiteUkExchanger, Facility facility) { var systemDictionary = Enumerable.ToList(ifcStore.Instances.OfType <IIfcRelAssignsToGroup>()) .Where(r => (r.RelatingGroup is IIfcSystem) && !(r.RelatingGroup is IIfcZone)) .ToDictionary(k => (IIfcSystem)k.RelatingGroup, v => v.RelatedObjects); facility.Systems = new List <Xbim.CobieLiteUk.System>(); foreach (var keyValue in systemDictionary) { Xbim.CobieLiteUk.System mappedSystem = ifcToCoBieLiteUkExchanger.mapSystem(keyValue.Key, new Xbim.CobieLiteUk.System()); facility.Systems.Add(mappedSystem); } var SystemAssignmentSet = ifcStore.Instances.OfType <IIfcRelAssignsToGroup>().Where(r => r.RelatingGroup is IIfcSystem) .Distinct(new IfcRelAssignsToGroupRelatedGroupObjCompare()); var ret = SystemAssignmentSet.ToDictionary(k => (IIfcSystem)k.RelatingGroup, v => v.RelatedObjects); foreach (var systemAssignment in ret) { var name = systemAssignment.Key.Name; Xbim.CobieLiteUk.System foundSystem = facility.Systems.Find(system => system.Name.Equals(name)); if (foundSystem != null) { IItemSet <IIfcObjectDefinition> components = systemAssignment.Value; foreach (var component in components) { if (!(component is IIfcSystem)) { var assetKey = new AssetKey(); assetKey.Name = component.Name; List <AssetKey> systemComponents = foundSystem.Components != null ? foundSystem.Components : new List <AssetKey>(); systemComponents.Add(assetKey); foundSystem.Components = systemComponents; } } } } }
private Task <String> ConvertIfcToCobieLiteUkAsync(IfcStore ifcStore, string fileName) { return(Task.Run <String>(() => { var defaultExtSystem = "LIBAL"; var siteName = ""; var phase = ""; var psetPropertyToUnitDictionary = new Dictionary <string, string>(); bool isIfc2x3 = ifcStore.SchemaVersion == Xbim.Common.Step21.XbimSchemaVersion.Ifc2X3; if (isIfc2x3) { Ifc2x3IfcEntityLabelGenerator.enrichModelWithIfcEntityLabel(ifcStore); defaultExtSystem = Ifc2x3IfcEntityLabelGenerator.getExtSystem(ifcStore); siteName = Ifc2x3IfcEntityLabelGenerator.getSiteName(ifcStore); phase = Ifc2x3IfcEntityLabelGenerator.getPhase(ifcStore); Ifc2x3QuantitySetGenerator.ResolveQuantitySet(ifcStore); Ifc2x3UnitResolver.ResolveUnits(ifcStore, psetPropertyToUnitDictionary); } else { Ifc4x1IfcEntityLabelGenerator.enrichModelWithIfcEntityLabel(ifcStore); defaultExtSystem = Ifc4x1IfcEntityLabelGenerator.getExtSystem(ifcStore); siteName = Ifc4x1IfcEntityLabelGenerator.getSiteName(ifcStore); phase = Ifc4x1IfcEntityLabelGenerator.getPhase(ifcStore); Ifc4x1QuantitySetGenerator.ResolveQuantitySet(ifcStore); Ifc4x1UnitResolver.ResolveUnits(ifcStore, psetPropertyToUnitDictionary); } var memStream = new MemoryStream(); var facilities = new List <Facility>(); var ifcToCoBieLiteUkExchanger = new LibalIfcToCOBieLiteUkExchanger(ifcStore, facilities, null, null, null, EntityIdentifierMode.GloballyUniqueIds, SystemExtractionMode.System); facilities = ifcToCoBieLiteUkExchanger.Convert(); var facility = facilities.ToArray()[0]; if (facility.Site != null) { facility.Site.Name = siteName; } facility.Phase = phase; AddUnitsToAttributes(facility, psetPropertyToUnitDictionary); CobieLiteUkAttributeResolver.resolveCobieAttributes(facility); ResolveContacts(facility, defaultExtSystem); MapSystems(ifcStore, ifcToCoBieLiteUkExchanger, facility); if (ifcStore.SchemaVersion == Xbim.Common.Step21.XbimSchemaVersion.Ifc2X3) { Ifc2x3IfcEntityLabelGenerator.resolveExtObjectWithPredefinedType(ifcStore, facility); } else { Ifc4x1IfcEntityLabelGenerator.resolveExtObjectWithPredefinedType(ifcStore, facility); } facility.ValidateUK2012(Console.Out, true); SetCorrectQSetName(facility); SetCorrectPsetName(facility); CleanupSystems(facility); CleanupZones(facility); // set ifc version in facility metadata facility.Metadata.Status = ifcStore.SchemaVersion.ToString(); facility.WriteXml(memStream); _s3.Create(fileName, new MemoryStream(memStream.ToArray())); return "processed"; })); }