private IEnumerable <IPersistIfcEntity> FilterElementsByType(IEnumerable <IPersistIfcEntity> elements, IEnumerable <IPersistIfcEntity> types) { //create lists from input arguments because enumeration crashes otherwise List <IPersistIfcEntity> elemList = elements.ToList(); List <IPersistIfcEntity> typeList = types.ToList(); foreach (var element in elemList) { IfcObject obj = element as IfcObject; if (obj != null) { IfcTypeObject defType = obj.GetDefiningType(); if (defType != null) { if (typeList.Contains(defType)) { yield return(element); } } else { yield return(element); } } } }
private void FillTypeData() { if (_typeProperties.Count > 0) { return; //don't fill unless empty } IfcObject ifcObj = _entity as IfcObject; if (ifcObj != null) { IfcTypeObject typeEntity = ifcObj.GetDefiningType(); if (typeEntity != null) { IfcType ifcType = IfcMetaData.IfcType(typeEntity); _typeProperties.Add(new PropertyItem() { Name = "Type", Value = ifcType.Type.Name }); _typeProperties.Add(new PropertyItem() { Name = "Ifc Label", Value = "#" + typeEntity.EntityLabel }); _typeProperties.Add(new PropertyItem() { Name = "Name", Value = typeEntity.Name }); _typeProperties.Add(new PropertyItem() { Name = "Description", Value = typeEntity.Description }); _typeProperties.Add(new PropertyItem() { Name = "GUID", Value = typeEntity.GlobalId }); _typeProperties.Add(new PropertyItem() { Name = "Ownership", Value = typeEntity.OwnerHistory.OwningUser.ToString() + " using " + typeEntity.OwnerHistory.OwningApplication.ApplicationIdentifier }); //now do properties in further specialisations that are text labels foreach (var pInfo in ifcType.IfcProperties.Where (p => p.Value.IfcAttribute.Order > 4 && p.Value.IfcAttribute.State != IfcAttributeState.DerivedOverride) ) //skip the first for of root, and derived and things that are objects { object val = pInfo.Value.PropertyInfo.GetValue(typeEntity, null); if (val != null && val is ExpressType) //only do express types { PropertyItem pi = new PropertyItem() { Name = pInfo.Value.PropertyInfo.Name, Value = ((ExpressType)val).ToPart21 }; _typeProperties.Add(pi); } } } } }