Пример #1
0
        /// <summary>
        /// Set values for attribute sheet
        /// </summary>
        /// <param name="ifcTypeObject">ifcObject to extract properties from</param>
        /// <param name="_attributes">The attribute Sheet to add the properties to its rows</param>
        public void PopulateAttributesRows(IfcTypeObject ifcTypeObject)
        {
            if (PropertSetValues.PSetFilterOn) //we have a property set filter set in the PropertSetValues class, so reset to retrieve all property sets for this object
            {
                PropertSetValues.SetAllPropertyValues(ifcTypeObject);
            }

            foreach (KeyValuePair <IfcPropertySet, IEnumerable <IfcSimpleProperty> > pairValues in PropertSetValues.MapPsetToProps)
            {
                IfcPropertySet ps = pairValues.Key; //get Property Set
                //get all property attached to the property set
                //check property set exclude list
                if (!string.IsNullOrEmpty(ps.Name))
                {
                    if (ExcludeAttributePropertySetNames.Count() > 0)
                    {
                        if (ExcludeAttributePropertySetNames.Contains(ps.Name))
                        {
                            continue; //skip this loop iteration if property set name matches exclude list item
                        }
                    }
                }

                IEnumerable <IfcSimpleProperty> pSVs = pairValues.Value; //Get Property SetAttribSheet Property Single Values
                //filter on ExcludePropertyValueNames and ExcludePropertyValueNamesWildcard
                pSVs = FilterRows(pSVs);
                //fill in the data to the attribute rows
                ProcessAttributeRow(ps, pSVs);
            }
        }
Пример #2
0
        internal bool isClassified(string classificationId, string classificationName, IfcObjectDefinition obj)
        {
            List <IfcRelAssociatesClassification> references = obj.HasAssociations.OfType <IfcRelAssociatesClassification>().ToList();

            if (obj is IfcObject ifcObject)
            {
                IfcTypeObject typeObject = ifcObject.RelatingType();
                if (typeObject != null)
                {
                    references.AddRange(typeObject.HasAssociations.OfType <IfcRelAssociatesClassification>());
                }
            }

            foreach (IfcClassificationReference classificationReference in references.Select(x => x.RelatingClassification).OfType <IfcClassificationReference>())
            {
                if (string.Compare(classificationId, classificationReference.Identification, true) == 0)
                {
                    if (string.IsNullOrEmpty(classificationName))
                    {
                        return(true);
                    }
                    IfcClassification classification = classificationReference.ReferencedClassification();
                    if (classification != null && string.Compare(classification.Name, classificationName, true) == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #3
0
        public override string WhereRule()
        {
            string err = "";

            if (_liningDepth.HasValue && !_liningThickness.HasValue)
            {
                err +=
                    "WR31 WindowLiningProperties : Either both parameter, LiningDepth and LiningThickness are given, or only the LiningThickness, then the LiningDepth is variable. It is not valid to only assert the LiningDepth.\n";
            }
            if (_secondTransomOffset.HasValue && !_firstTransomOffset.HasValue)
            {
                err +=
                    "WR32 WindowLiningProperties : Either both parameter, FirstTransomOffset and SecondTransomOffset are given, or only the FirstTransomOffset, or none of both. It is not valid to only assert the SecondTransomOffset.\n";
            }
            if (_secondMullionOffset.HasValue && !_firstMullionOffset.HasValue)
            {
                err +=
                    "WR33 WindowLiningProperties : Either both parameter, FirstMullionOffset and SecondMullionOffset are given, or only the FirstMullionOffset, or none of both. It is not valid to only assert the SecondMullionOffset.\n";
            }
            IfcTypeObject defines = DefinesType.FirstOrDefault();

            if (defines != null && !(defines is IfcWindowStyle))
            {
                err +=
                    "WR34 WindowLiningProperties : The WindowLiningProperties shall only be used in the context of an WindowStyle.\n";
            }
            return(err);
        }
        /// <summary>
        /// Set the property sets mapped to list of simple property values held for the IfcTypeObject
        /// filtered by a IfcPropertySet name
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject holding the property values</param>
        /// <param name="propertySetNames">List of IfcPropertySetName</param>
        public void SetAllPropertyValues(IfcTypeObject ifcTypeObject, List <string> propertySetNames)
        {
            _currentObject = ifcTypeObject;
            PSetFilterOn   = true;

            if (ifcTypeObject.HasPropertySets != null) //we have properties to get
            {
                _mapPsetToProps = ifcTypeObject.HasPropertySets.OfType <IfcPropertySet>()
                                  .Where(ps => (propertySetNames.Contains(ps.Name)))
                                  .ToDictionary(ps => ps, ps => ps.HasProperties.OfType <IfcSimpleProperty>());
            }
            else
            {
                _mapPsetToProps.Clear(); //clear as we have no properties for this object
            }

            //fall back to related items to get the information from
            if (!_mapPsetToProps.Any())//not sure we should do this, but we get values to fill from an object that is using the type object
            {
                if (ifcTypeObject.ObjectTypeOf.Any())
                {
                    IfcObject IfcObj = ifcTypeObject.ObjectTypeOf.First().RelatedObjects.FirstOrDefault();
                    if (IfcObj != null)
                    {
                        SetAllPropertyValues(IfcObj); //we do not filter on property set name here, just go for all of them
                    }
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Get the Replacement Cost for the IfcTypeObject
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcSpace</param>
        /// <returns>property value as string or default value</returns>
        private string GetReplacementCost(IfcTypeObject ifcTypeObject, COBieDataPropertySetValues allPropertyValues)
        {
            allPropertyValues.SetAllPropertyValues(ifcTypeObject, "COBie_EconomicImpactValues"); //changed from "Pset_EconomicImpactValues" on v16 of matrix
            string value = allPropertyValues.GetPropertySingleValueValue("ReplacementCost", false);

            //Fall back to wild card properties
            //get the property single values for this ifcTypeObject
            if (value == DEFAULT_STRING)
            {
                allPropertyValues.SetAllPropertyValues(ifcTypeObject);
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("ReplacementCost", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("Replacement Cost", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("Cost", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("Replacement", true);
                }
            }
            return(((string.IsNullOrEmpty(value)) || (value == DEFAULT_STRING) || (!IsNumeric(value))) ? DEFAULT_NUMERIC : value);
        }
        public override string WhereRule()
        {
            string err = "";

            if (_liningDepth.HasValue && !_liningThickness.HasValue)
            {
                err +=
                    "WR31 DoorLiningProperties: Either both parameter, LiningDepth and LiningThickness are given, or only the LiningThickness, then the LiningDepth is variable. It is not valid to only assert the LiningDepth.\n";
            }
            if (_thresholdDepth.HasValue && !_thresholdThickness.HasValue)
            {
                err +=
                    "WR32 DoorLiningProperties: Either both parameter, ThresholdDepth and ThresholdThickness are given, or only the ThresholdThickness, then the ThresholdDepth is variable. It is not valid to only assert the ThresholdDepth\n";
            }
            if (_transomOffset.HasValue ^ _transomThickness.HasValue)
            {
                err +=
                    "WR33 DoorLiningProperties: Either both parameter, TransomOffset and TransomThickness are given, or neither of them.\n";
            }
            if (_casingDepth.HasValue ^ _casingThickness.HasValue)
            {
                err +=
                    "WR34 DoorLiningProperties: Either both parameter, the CasingDepth and the CasingThickness, are given, or neither of them.\n";
            }
            IfcTypeObject defType = DefinesType.FirstOrDefault();

            if (defType != null && !(defType is IfcDoorStyle))
            {
                err +=
                    "WR35 DoorLiningProperties: The IfcDoorLiningProperties shall only be used in the context of an IfcDoorStyle.\n";
            }
            return(err);
        }
Пример #7
0
        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);
                        }
                    }
                }
            }
        }
Пример #9
0
 /// <summary>
 /// Use this method to get all element quantities related to this object
 /// </summary>
 /// <returns>All related element quantities</returns>
 public static IEnumerable <IfcElementQuantity> GetAllElementQuantities(this IfcTypeObject elem)
 {
     if (elem.HasPropertySets != null)
     {
         return(elem.HasPropertySets.OfType <IfcElementQuantity>());
     }
     return(new IfcElementQuantity[] { });
 }
        public bool isApplicable(IfcFlowSegment flowSegment)
        {
            // Doubled up Ifc Classification and Uniclass to be confirmed....
            IfcPropertySingleValue propertySingleValue = null;
            IfcSystem system = flowSegment.HasAssignments.OfType <IfcRelAssignsToGroup>().Select(x => x.RelatingGroup).OfType <IfcSystem>().FirstOrDefault();

            if (system != null)
            {
                propertySingleValue = system.FindProperty("TfNSW_Uniclass_AssetCode") as IfcPropertySingleValue;
                if (propertySingleValue != null)
                {
                    if (!propertySingleValue.ValueStringStartsWith("Ss_50_30"))                     //Drainage collection and distribution systems
                    {
                        return(false);
                    }
                }
                IfcDistributionSystem distributionSystem = system as IfcDistributionSystem;
                if (distributionSystem != null)                 //IFC4 concept
                {
                    if (distributionSystem.PredefinedType != IfcDistributionSystemEnum.DRAINAGE)
                    {
                        return(false);
                    }
                }
            }

            propertySingleValue = flowSegment.FindProperty("TfNSW_Uniclass_AssetCode") as IfcPropertySingleValue;
            if (propertySingleValue != null)
            {
                if (propertySingleValue.ValueStringStartsWith("Pr_65_52_63"))                 // Pipes and fittings
                {
                    return(true);
                }
            }

            if (flowSegment is IfcDuctSegment)
            {
                return(false);
            }
            if (flowSegment is IfcCableCarrierSegment)
            {
                return(false);
            }

            IfcTypeObject typeObject = flowSegment.RelatingType();

            if (typeObject is IfcDuctSegmentType)
            {
                return(false);
            }
            if (typeObject is IfcCableCarrierSegmentType)
            {
                return(false);
            }

            return(true);
        }
Пример #11
0
        public override string WhereRule()
        {
            IfcTypeObject defType = DefinesType.FirstOrDefault();

            if (defType != null && !(defType is IfcDoorStyle))
            {
                return
                    ("WR31 DoorPanelProperties: The DoorPanelProperties shall only be used in the context of an IfcDoorStyle. ");
            }
            return("");
        }
Пример #12
0
        public static IfcElementQuantity GetElementQuantity(this IfcTypeObject elem, string pSetName, bool caseSensitive = true)
        {
            if (elem.HasPropertySets == null)
            {
                return(null);
            }

            return(caseSensitive ?
                   elem.HasPropertySets.Where <IfcElementQuantity>(r => r.Name == pSetName).FirstOrDefault() :
                   elem.HasPropertySets.Where <IfcElementQuantity>(r => r.Name.ToString().ToLower() == pSetName.ToLower()).FirstOrDefault()
                   );
        }
Пример #13
0
        public static void RemoveElementPhysicalSimpleQuantity(this IfcTypeObject elem, string pSetName, string qualityName)
        {
            IfcElementQuantity elementQuantity = GetElementQuantity(elem, pSetName);

            if (elementQuantity != null)
            {
                IfcPhysicalSimpleQuantity simpleQuantity = elementQuantity.Quantities.Where <IfcPhysicalSimpleQuantity>(sq => sq.Name == qualityName).FirstOrDefault();
                if (simpleQuantity != null)
                {
                    elementQuantity.Quantities.Remove(simpleQuantity);
                }
            }
        }
Пример #14
0
        public static IfcPhysicalSimpleQuantity GetElementPhysicalSimpleQuantity(this IfcTypeObject elem, string pSetName, string qualityName)
        {
            IfcElementQuantity elementQuality = GetElementQuantity(elem, pSetName);

            if (elementQuality != null)
            {
                return(elementQuality.Quantities.Where <IfcPhysicalSimpleQuantity>(sq => sq.Name == qualityName).FirstOrDefault());
            }
            else
            {
                return(null);
            }
        }
Пример #15
0
        /// <summary>
        /// Get the Expected Life for the IfcTypeObject
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcSpace</param>
        /// <returns>property value as string or default value</returns>
        private string GetExpectedLife(IfcTypeObject ifcTypeObject, Interval serviceDuration, COBieDataPropertySetValues allPropertyValues)
        {
            string value = serviceDuration.Value;

            //Fall back to wild card properties
            //get the property single values for this ifcTypeObject
            allPropertyValues.SetAllPropertyValues(ifcTypeObject);
            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("ServiceLifeDuration", true);
            }
            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue(" Expected", true);
            }
            return(((string.IsNullOrEmpty(value)) || (value == DEFAULT_STRING) || (!IsNumeric(value))) ? DEFAULT_NUMERIC : value);
        }
Пример #16
0
        /// <summary>
        /// Return the Description for the passed IfcTypeObject object
        /// </summary>
        /// <param name="type">IfcTypeObject</param>
        /// <returns>Description for Type Object</returns>
        private string GetTypeObjDescription(IfcTypeObject type)
        {
            if (type != null)
            {
                if (!string.IsNullOrEmpty(type.Description))
                {
                    return(type.Description);
                }
                else if (!string.IsNullOrEmpty(type.Name))
                {
                    return(type.Name);
                }

                //if supports PredefinedType and no description or name then use the predefined type or ElementType if they exist
                IEnumerable <PropertyInfo> pInfo = type.GetType().GetProperties(); //get properties
                var predefinedType = pInfo.Where(p => p.Name == "PredefinedType").FirstOrDefault();
                if (predefinedType != null)
                {
                    string temp = predefinedType.GetValue(type, null).ToString(); //get predefindtype as description

                    if (!string.IsNullOrEmpty(temp))
                    {
                        if (temp == "USERDEFINED")
                        {
                            //if used defined then the type description should be in ElementType, so see if property exists
                            var elementType = pInfo.Where(p => p.Name == "ElementType").FirstOrDefault();
                            if (elementType != null)
                            {
                                temp = elementType.GetValue(type, null).ToString(); //get ElementType
                                if (!string.IsNullOrEmpty(temp))
                                {
                                    return(temp);
                                }
                            }
                        }
                        if (temp == "NOTDEFINED") //if not defined then give up and return default
                        {
                            return(DEFAULT_STRING);
                        }

                        return(temp);
                    }
                }
            }
            return(DEFAULT_STRING);
        }
Пример #17
0
        /// <summary>
        /// Get the Asset Type from the property set property if nothing found then default to Moveable/Fixed decided on object type
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject Object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holding the property sets</param>
        /// <returns>String holding Asset Type</returns>
        private string GetAssetType(IfcTypeObject ifcTypeObject, COBieDataPropertySetValues allPropertyValues)
        {
            string value = allPropertyValues.GetPropertySingleValueValue("AssetAccountingType", false);

            if (value == DEFAULT_STRING)
            {
                if (ifcTypeObject is IfcFurnitureType)
                {
                    value = "Moveable";
                }
                else
                {
                    value = "Fixed";
                }
            }
            return(value);
        }
Пример #18
0
        /// <summary>
        /// Get the list or properties matching the passed in list of attribute names
        /// </summary>
        /// <param name="typeObj">IfcTypeObject </param>
        /// <param name="attNames">list of attribute names</param>
        /// <returns>List of IfcPropertySingleValue which are contained in AttNames</returns>
        private IEnumerable <IfcPropertySingleValue> GetTypeObjRelAttributes(IfcTypeObject typeObj, List <string> attNames)
        {
            var properties = Enumerable.Empty <IIfcPropertySingleValue>();
            // can hold zero or 1 ObjectTypeOf (IfcRelDefinesByType- holds list of objects of this type in RelatedObjects property) so test return
            var typeInstanceRel = typeObj.ObjectTypeOf.FirstOrDefault();

            if (typeInstanceRel != null)
            {
                // TODO: Check usage of GetAllProperties - duplicates Properties from Type?
                foreach (var pset in typeInstanceRel.RelatedObjects.First().PropertySets)
                {
                    //has to have 1 or more object that are of this type, so get first and see what we get
                    properties = properties.Concat(pset.HasProperties.OfType <IIfcPropertySingleValue>().Where(p => attNames.Contains(p.Name.ToString())));
                }
            }


            return(properties.Cast <IfcPropertySingleValue>());
        }
Пример #19
0
        /// <summary>
        /// Get the Model Number for the IfcTypeObject
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcSpace</param>
        /// <returns>property value as string or default value</returns>
        private string GetModelNumber(IfcTypeObject ifcTypeObject, COBieDataPropertySetValues allPropertyValues)
        {
            string value = allPropertyValues.GetPropertySingleValueValue("ModelLabel", false);

            //Fall back to wild card properties
            //get the property single values for this ifcTypeObject
            if (value == DEFAULT_STRING)
            {
                allPropertyValues.SetAllPropertyValues(ifcTypeObject);
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("ArticleNumber", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("ModelLabel", true);
                }
            }
            return((string.IsNullOrEmpty(value)) ? DEFAULT_STRING : value);
        }
Пример #20
0
        /// <summary>
        /// Get the Warranty Guarantor Parts for the IfcTypeObject
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcSpace</param>
        /// <returns>property value as string or default value</returns>
        private string GetWarrantyGuarantorParts(IfcTypeObject ifcTypeObject, COBieDataPropertySetValues allPropertyValues)
        {
            string value = allPropertyValues.GetPropertySingleValueValue("WarrantyGuarantorParts", false);

            //Fall back to wild card properties
            //get the property single values for this ifcTypeObject
            if (value == DEFAULT_STRING)
            {
                allPropertyValues.SetAllPropertyValues(ifcTypeObject);
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("WarrantyGuarantorParts", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("PointOfContact", true);
                }
            }
            return((((string.IsNullOrEmpty(value)) || (value == DEFAULT_STRING)) || (!IsEmailAddress(value))) ? Constants.DEFAULT_EMAIL : value);
        }
Пример #21
0
        /// <summary>
        /// Get the Warranty Description for the IfcTypeObject
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcSpace</param>
        /// <returns>property value as string or default value</returns>
        private string GetWarrantyDescription(IfcTypeObject ifcTypeObject, COBieDataPropertySetValues allPropertyValues)
        {
            string value = allPropertyValues.GetPropertySingleValueValue("WarrantyDescription", false);

            //Fall back to wild card properties
            //get the property single values for this ifcTypeObject
            if (value == DEFAULT_STRING)
            {
                allPropertyValues.SetAllPropertyValues(ifcTypeObject);
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("WarrantyDescription", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("WarrantyIdentifier", true);
                }
            }
            return((string.IsNullOrEmpty(value)) ? DEFAULT_STRING : value);
        }
Пример #22
0
            public static Core ExtractType(IfcElement ifcele)
            {
                IfcTypeObject ifctype = ifcele.IsTypedBy.RelatingType;
                FinishLib     flib    = new FinishLib();

                flib.FKey_Category = Category.GetorAddCategory(ifctype.Name.Split(':')[0]).GuId;
                ExtractTypicalProperties(ifctype, flib);
                flib.Name = ifctype.Name.Split(':')[1];

                var d = new Data("PreDefined ObjectType", ifctype.GetPredefinedType());

                flib.Additional_Info.Add(d);

                flib.Additional_Info.ForEach(dx =>
                {
                    dx.SetFkeyParent(flib);
                });

                return(flib);
            }
Пример #23
0
        /// <summary>
        /// Get the Constituents for the IfcTypeObject
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcSpace</param>
        /// <returns>property value as string or default value</returns>
        private string GetConstituents(IfcTypeObject ifcTypeObject, COBieDataPropertySetValues allPropertyValues)
        {
            string value = allPropertyValues.GetPropertySingleValueValue("Constituents", false);

            //Fall back to wild card properties
            //get the property single values for this ifcTypeObject
            if (value == DEFAULT_STRING)
            {
                allPropertyValues.SetAllPropertyValues(ifcTypeObject);
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("constituents", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("parts", true);
                }
            }
            return((string.IsNullOrEmpty(value)) ? DEFAULT_STRING : value);
        }
Пример #24
0
        /// <summary>
        /// Get the Sustainability Performance for the IfcTypeObject
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcSpace</param>
        /// <returns>property value as string or default value</returns>
        private string GetSustainabilityPerformance(IfcTypeObject ifcTypeObject, COBieDataPropertySetValues allPropertyValues)
        {
            string value = allPropertyValues.GetPropertySingleValueValue("SustainabilityPerformance", false);

            //Fall back to wild card properties
            //get the property single values for this ifcTypeObject
            if (value == DEFAULT_STRING)
            {
                allPropertyValues.SetAllPropertyValues(ifcTypeObject);
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("SustainabilityPerformance", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("Environmental", true);
                }
            }
            return((string.IsNullOrEmpty(value)) ? DEFAULT_STRING : value);
        }
Пример #25
0
        /// <summary>
        /// Get the Model Reference for the IfcTypeObject
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcSpace</param>
        /// <returns>property value as string or default value</returns>
        private string GetModelReference(IfcTypeObject ifcTypeObject, COBieDataPropertySetValues allPropertyValues)
        {
            allPropertyValues.SetAllPropertyValues(ifcTypeObject, "Pset_ManufacturersTypeInformation");
            string value = allPropertyValues.GetPropertySingleValueValue("ModelReference", false);

            //Fall back to wild card properties
            //get the property single values for this ifcTypeObject
            if (value == DEFAULT_STRING)
            {
                allPropertyValues.SetAllPropertyValues(ifcTypeObject);
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("ModelReference", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("Reference", true);
                }
            }
            return((string.IsNullOrEmpty(value)) ? DEFAULT_STRING : value);
        }
Пример #26
0
        /// <summary>
        /// Check all ifcElements associated with the pass ifcTypeObject for the passed property map key.
        /// If all found elements of the property are the same then we assume that the property applies to the type as well as all the elements
        /// </summary>
        /// <param name="valueName">property map key</param>
        /// <param name="ifcTypeObject">ifcTypeObject</param>
        /// <returns>property value</returns>
        private string GetObjPropByAssoc(string valueName, IfcTypeObject ifcTypeObject)
        {
            string accCategoryString = string.Empty;
            var    ObjDefByType      = _helper.DefiningTypeObjectMap.Where(pair => (pair.Key.IfcTypeObject != null) && (pair.Key.IfcTypeObject == ifcTypeObject)).SelectMany(p => p.Value);
            var    assetTypes        = new List <string>();

            foreach (var item in ObjDefByType)
            {
                accCategoryString = _helper.GetCoBieProperty(valueName, item);
                assetTypes.Add(accCategoryString != null ? accCategoryString : string.Empty);
            }
            //assume every ifcElement hast to have the value and be set to the same value
            if (assetTypes.Count > 0)
            {
                var fat = assetTypes.First();
                if (assetTypes.All(at => at == fat))
                {
                    return(accCategoryString);
                }
            }
            return(null);
        }
Пример #27
0
        /// <summary>
        /// Create an Instance of a Object Type
        /// </summary>
        /// <param name="typeName">string name to create instance of</param>
        /// <param name="model">Model object</param>
        /// <returns>IfcTypeObject object of the type passed in of IfcTypeObject if failed to create passed in type</returns>
        public static IfcTypeObject GetTypeInstance(string typeName, IModel model)
        {
            typeName = typeName.Trim().ToUpper();

            IfcType       ifcType;
            IfcTypeObject ifcTypeObject = null;

            if (IfcMetaData.TryGetIfcType(typeName, out ifcType))
            {
                MethodInfo method  = typeof(IXbimInstanceCollection).GetMethod("New", Type.EmptyTypes);
                MethodInfo generic = method.MakeGenericMethod(ifcType.Type);
                var        newObj  = generic.Invoke(model.Instances, null);
                if (newObj is IfcTypeObject)
                {
                    ifcTypeObject = (IfcTypeObject)newObj;
                }
            }
            if (ifcTypeObject == null) //if we cannot make a object assume base IfcTypeObject
            {
                ifcTypeObject = model.Instances.New <IfcTypeObject>();
            }
            return(ifcTypeObject);
        }
Пример #28
0
        //TODO: Check function below, see if it works!
        /// <summary>
        /// filter on IfcObjectDefinition objects
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>bool true = exclude</returns>
        public bool ObjFilter(IfcObjectDefinition obj, bool checkType = true)
        {
            bool exclude = false;

            if (obj is IfcProduct)
            {
                exclude = IfcProductFilter.ItemsFilter(obj);
                //check the element is not defined by a type which is excluded, by default if no type, then no element included
                if (!exclude && checkType)
                {
                    IfcTypeObject objType = ((IfcProduct)obj).IsDefinedBy.OfType <IfcRelDefinesByType>().Select(rdbt => rdbt.RelatingType).FirstOrDefault(); //assuming only one IfcRelDefinesByType
                    if (objType != null)                                                                                                                     //if no type defined lets include it for now
                    {
                        exclude = IfcTypeObjectFilter.ItemsFilter(objType);
                    }
                }
            }
            else if (obj is IfcTypeProduct)
            {
                exclude = IfcTypeObjectFilter.ItemsFilter(obj);
            }
            return(FlipResult ? !exclude : exclude);
        }
Пример #29
0
        //Removes the current object from any RelDefinesByType relationships and adds a relationship to the specified Type
        public static void SetDefiningType(this IfcObject obj, IfcTypeObject typeObj, IModel model)
        {
            //divorce any exisitng related types
            IEnumerable <IfcRelDefinesByType> rels = model.Instances.Where <IfcRelDefinesByType>(rd => rd.RelatedObjects.Contains(obj));

            foreach (var rel in rels)
            {
                rel.RelatedObjects.Remove(obj);
            }
            //find any existing relationships to this type
            IfcRelDefinesByType typeRel = model.Instances.Where <IfcRelDefinesByType>(rd => rd.RelatingType == typeObj).FirstOrDefault();

            if (typeRel == null) //none defined create the relationship
            {
                IfcRelDefinesByType relSub = model.Instances.New <IfcRelDefinesByType>();
                relSub.RelatingType = typeObj;
                relSub.RelatedObjects.Add(obj);
            }
            else //we have the type
            {
                typeRel.RelatedObjects.Add(obj);
            }
        }
Пример #30
0
        /// <summary>
        /// Get the Nominal Length for the IfcTypeObject
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcSpace</param>
        /// <returns>property value as string or default value</returns>
        private string GetNominalLength(IfcTypeObject ifcTypeObject, COBieDataPropertySetValues allPropertyValues)
        {
            string value = allPropertyValues.GetPropertySingleValueValue("NominalLength", false);

            //Fall back to wild card properties
            //get the property single values for this ifcTypeObject
            if (value == DEFAULT_STRING)
            {
                allPropertyValues.SetAllPropertyValues(ifcTypeObject);
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("NominalLength", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("OverallLength", true);
                }
                if (value == DEFAULT_STRING)
                {
                    value = allPropertyValues.GetPropertySingleValueValue("Length", true);
                }
            }
            return(ConvertNumberOrDefault(value));
        }