コード例 #1
0
        public static bool Add(this IIfcPropertySetDefinition pSetDefinition, IIfcSimpleProperty prop)
        {
            var propSet = pSetDefinition as IIfcPropertySet;

            if (propSet != null)
            {
                propSet.HasProperties.Add(prop);
            }
            return(propSet != null);
        }
コード例 #2
0
        public static bool Add(this IIfcPropertySetDefinition pSetDefinition, IIfcPhysicalQuantity quantity)
        {
            var quantSet = pSetDefinition as IIfcElementQuantity;

            if (quantSet != null)
            {
                quantSet.Quantities.Add(quantity);
            }
            return(quantSet != null);
        }
コード例 #3
0
 public static IEnumerable <T> Properties <T>(this IIfcPropertySetDefinition set) where T : IIfcProperty
 {
     if (set is IIfcPropertySet pSet)
     {
         return(pSet.HasProperties.OfType <T>());
     }
     else
     {
         return(Enumerable.Empty <T>());
     }
 }
コード例 #4
0
        /// <summary />
        /// <param name="pSetDef"></param>
        public void AddPropertySetDefinition(IIfcPropertySetDefinition pSetDef)
        {
            if (string.IsNullOrWhiteSpace(pSetDef.Name))
            {
                Logger.LogWarning("Property Set Definition: #{entityId}, has no defined name. It has been ignored", pSetDef.EntityLabel);
                return;
            }
            if (_propertySets.ContainsKey(pSetDef.Name))
            {
                Logger.LogWarning("Property Set Definition: #{psetId}={psetName}, is duplicated in Entity #{entityId}={entityType}. Duplicate ignored",
                                  pSetDef.EntityLabel, pSetDef.Name, _ifcObject.EntityLabel, _ifcObject.GetType().Name);
                return;
            }
            _propertySets.Add(pSetDef.Name, pSetDef);
            var propertySet = pSetDef as IIfcPropertySet;
            var quantitySet = pSetDef as IIfcElementQuantity;

            if (propertySet != null)
            {
                foreach (var prop in propertySet.HasProperties)
                {
                    var uniquePropertyName = pSetDef.Name + "." + prop.Name;
                    if (_properties.ContainsKey(uniquePropertyName))
                    {
                        Logger.LogWarning("Property: #{propId}={psetName}.{propName}, is duplicated in Entity #{entityId}={entityType}. Duplicate ignored",
                                          prop.EntityLabel, pSetDef.Name, prop.Name, _ifcObject.EntityLabel, _ifcObject.GetType().Name);
                        continue;
                    }
                    _properties[uniquePropertyName] = prop;
                }
            }
            else if (quantitySet != null)
            {
                foreach (var quantity in quantitySet.Quantities)
                {
                    if (_quantities.ContainsKey(pSetDef.Name + "." + quantity.Name))
                    {
                        Logger.LogWarning("Quantity: #{qtyId}={psetName}.{qtyName}, is duplicated in Entity #{entityId}={entityType}. Duplicate ignored",
                                          quantity.EntityLabel, pSetDef.Name, quantity.Name, _ifcObject.EntityLabel, _ifcObject.GetType().Name);
                        continue;
                    }
                    _quantities[pSetDef.Name + "." + quantity.Name] = quantity;
                }
            }
        }
コード例 #5
0
        public void AddPropertySetDefinition(IIfcPropertySetDefinition pSetDef)
        {
            if (!pSetDef.Name.HasValue || string.IsNullOrWhiteSpace(pSetDef.Name))
            {
                CoBieLiteHelper.Logger.WarnFormat("Property Set Definition: #{0}, has no defined name. It has been ignored", pSetDef.EntityLabel);
                return;
            }
            if (_propertySets.ContainsKey(pSetDef.Name))
            {
                CoBieLiteHelper.Logger.WarnFormat("Property Set Definition: #{0}={1}, is duplicated in Entity #{2}={3}. Duplicate ignored", pSetDef.EntityLabel, pSetDef.Name, _ifcObject.EntityLabel, _ifcObject.GetType().Name);
                return;
            }
            _propertySets.Add(pSetDef.Name, pSetDef);
            var propertySet = pSetDef as IIfcPropertySet;
            var quantitySet = pSetDef as IIfcElementQuantity;

            if (propertySet != null)
            {
                foreach (var prop in propertySet.HasProperties)
                {
                    var uniquePropertyName = pSetDef.Name + "." + prop.Name;
                    if (_properties.ContainsKey(uniquePropertyName))
                    {
                        CoBieLiteHelper.Logger.WarnFormat("Property: #{0}={1}.{2}, is duplicated in Entity #{3}={4}. Duplicate ignored", prop.EntityLabel, pSetDef.Name, prop.Name, _ifcObject.EntityLabel, _ifcObject.GetType().Name);
                        continue;
                    }
                    _properties[uniquePropertyName] = prop;
                }
            }
            else if (quantitySet != null)
            {
                foreach (var quantity in quantitySet.Quantities)
                {
                    if (_quantities.ContainsKey(pSetDef.Name + "." + quantity.Name))
                    {
                        CoBieLiteHelper.Logger.WarnFormat("Quantity: #{0}={1}.{2}, is duplicated in Entity #{3}={4}. Duplicate ignored", quantity.EntityLabel, pSetDef.Name, quantity.Name, _ifcObject.EntityLabel, _ifcObject.GetType().Name);
                        continue;
                    }
                    _quantities[pSetDef.Name + "." + quantity.Name] = quantity;
                }
            }
        }
コード例 #6
0
        private string GetProperty(IIfcPropertySetDefinition matchingSet, PropertyDef singleProperty)
        {
            var asSet = matchingSet as IIfcPropertySet;

            if (asSet != null)
            {
                var found = asSet.HasProperties.OfType <IIfcPropertySingleValue>().FirstOrDefault(x => x.Name == singleProperty.Name);
                if (found != null)
                {
                    return(found.NominalValue.ToString());
                }
                foreach (var alias in singleProperty.NameAliases)
                {
                    found = asSet.HasProperties.OfType <IIfcPropertySingleValue>().FirstOrDefault(x => x.Name == singleProperty.Name);
                    if (found != null)
                    {
                        return(found.NominalValue.ToString());
                    }
                }
            }
            return("");
        }