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 41 forks source link

COBieLiteUK: Conversion from IFC, IfcSystems ignored #19

Open MichaelBuehler opened 7 years ago

MichaelBuehler commented 7 years ago

Hello,

Below code in Exchange > IfcToCOBieLiteUK > COBieLiteUKHelper.cs seems todo nothing: On Line 483, ret contains the correct list of systems, but ret is not used.

private void GetSystems()
    {
        _systemAssignment = new Dictionary<IIfcSystem, IItemSet<IIfcObjectDefinition>>();
        if (SystemMode.HasFlag(SystemExtractionMode.System))
        {
            var SystemAssignmentSet =
                    _model.Instances.OfType<IIfcRelAssignsToGroup>().Where(r => r.RelatingGroup is IIfcSystem)
                    .Distinct(new IfcRelAssignsToGroupRelatedGroupObjCompare()); //make sure we do not have duplicate keys, or ToDictionary will throw ex. could lose RelatedObjects though. 
            var ret = SystemAssignmentSet.ToDictionary(k => (IIfcSystem)k.RelatingGroup, v => v.RelatedObjects);
            _systemLookup = new Dictionary<IIfcObjectDefinition, List<IIfcSystem>>();
            ReportProgress.NextStage(SystemAssignment.Count, 35);
            foreach (var systemAssignment in SystemAssignment)
            {
                foreach (var objectDefinition in systemAssignment.Value)
                {
                    if (_systemLookup.ContainsKey(objectDefinition))
                        _systemLookup[objectDefinition].Add(systemAssignment.Key);
                    else
                        _systemLookup.Add(objectDefinition, new List<IIfcSystem>(new[] { systemAssignment.Key }));
                }
                ReportProgress.IncrementAndUpdate();
            }
        }

Consider to copy ret into SystemAssignment: foreach(var item in ret) _systemAssignment.Add(item.Key, item.Value);

simiii commented 3 years ago

@MichaelBuehler how did you fix this?