/// <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);
        }
Beispiel #2
0
        /// <summary>
        /// Get space gross floor area
        /// </summary>
        /// <param name="ifcSpace">IfcSpace 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 GetGrossFloorArea(IfcSpace ifcSpace, COBieDataPropertySetValues allPropertyValues)
        {
            string areaUnit  = null;
            double areavalue = 0.0;

            if (!string.IsNullOrEmpty(Context.WorkBookUnits.AreaUnit))
            {
                areaUnit = Context.WorkBookUnits.AreaUnit;//see what the global area unit is
            }
            //Do Gross Areas
            IfcAreaMeasure?grossAreaValue = ifcSpace.GrossFloorArea;

            if (grossAreaValue != null)
            {
                areavalue = ((double)grossAreaValue);
            }
            else//if we fail on IfcAreaMeasure try GSA keys
            {
                IfcQuantityArea spArea = ifcSpace.GetQuantity <IfcQuantityArea>("GSA Space Areas", "GSA BIM Area");
                areavalue = spArea.AreaValue;
            }
            if (areavalue > 0.0)
            {
                //if ((!string.IsNullOrEmpty(areaUnit)) && (areaUnit.ToLower().Contains("milli")) && (areavalue > 250000.0)) //we are using millimetres, and areavalue is lightly to be in mmsq if over 250000(0.5msq)
                //    areavalue = areavalue / 1000000.0;

                return(areavalue.ToString(CultureInfo.InvariantCulture));
            }

            //Fall back to properties
            //get the property single values for this ifcSpace
            if (allPropertyValues.CurrentObject != ifcSpace)
            {
                allPropertyValues.SetAllPropertyValues(ifcSpace);
            }

            //try and find it in the attached properties of the ifcSpace
            string value = allPropertyValues.GetPropertySingleValueValue("GrossFloorArea", true);

            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("GSA", true);
            }

            if (value == DEFAULT_STRING)
            {
                return(DEFAULT_NUMERIC);
            }
            else
            {
                if (double.TryParse(value, out areavalue))
                {
                    //if ((!string.IsNullOrEmpty(areaUnit)) && (areaUnit.ToLower().Contains("milli")) && (areavalue > 250000.0))//we are using millimetres, and areavalue is lightly to be in mmsq if over 250000(0.5msq)
                    //    areavalue = areavalue / 1000000.0;
                    return(areavalue.ToString());
                }
                return(value);
            }
        }
        /// <summary>
        /// Get Net Area value
        /// </summary>
        /// <param name="ifcSpace">IfcSpace 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 GetNetArea(IfcSpace ifcSpace, COBieDataPropertySetValues allPropertyValues)
        {
            string areaUnit  = null;
            double areavalue = 0.0;

            if (!string.IsNullOrEmpty(Context.WorkBookUnits.AreaUnit))
            {
                areaUnit = Context.WorkBookUnits.AreaUnit;            //see what the global area unit is
            }
            IfcAreaMeasure netAreaValue = ifcSpace.GetNetFloorArea(); //this extension has the GSA built in so no need to get again

            if (netAreaValue != null)
            {
                areavalue = ((double)netAreaValue);
                if (areavalue > 0.0)
                {
                    //if ((!string.IsNullOrEmpty(areaUnit)) && (areaUnit.ToLower().Contains("milli")) && (areavalue > 250000.0)) //we are using millimetres, and areavalue is lightly to be in mmsq if over 250000(0.5msq)
                    //    areavalue = areavalue / 1000000.0;

                    return(areavalue.ToString("F4"));
                }
            }

            //Fall back to properties
            //get the property single values for this ifcSpace
            if (allPropertyValues.CurrentObject != ifcSpace)
            {
                allPropertyValues.SetAllPropertyValues(ifcSpace);
            }


            //try and find it in the attached properties of the ifcSpace
            string value = allPropertyValues.GetPropertySingleValueValue("NetFloorArea", true);

            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("GSA", true);
            }

            if (value == DEFAULT_STRING)
            {
                return(DEFAULT_NUMERIC);
            }
            else
            {
                if (double.TryParse(value, out areavalue))
                {
                    //if ((!string.IsNullOrEmpty(areaUnit)) && (areaUnit.ToLower().Contains("milli")) && (areavalue > 250000.0))//we are using millimetres, and areavalue is lightly to be in mmsq if over 250000(0.5msq)
                    //    areavalue = areavalue / 1000000.0;
                    return(areavalue.ToString("F4"));
                }
                return(value);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Get the floor height
        /// </summary>
        /// <param name="ifcBuildingStorey">IfcBuildingStory object</param>
        /// <param name="allPropertyValues">COBieDataPropertySetValues object holds all the properties for all the IfcBuildingStory </param>
        /// <returns></returns>
        private string GetFloorHeight(IfcBuildingStorey ifcBuildingStorey, COBieDataPropertySetValues allPropertyValues)
        {
            //try for a IfcQuantityLength related property to this building story
            IEnumerable <IfcQuantityLength> qLen = ifcBuildingStorey.IsDefinedByProperties.Select(p => p.RelatedObjects.OfType <IfcQuantityLength>()).FirstOrDefault();

            if (qLen != null && qLen.FirstOrDefault() != null)
            {
                return(qLen.FirstOrDefault().LengthValue.ToString());
            }

            //Fall back properties
            //get the property single values for this building story
            if (ifcBuildingStorey != allPropertyValues.CurrentObject)
            {
                allPropertyValues.SetAllPropertyValues(ifcBuildingStorey);
            }

            //try and find it in the attached properties of the building story
            string value = allPropertyValues.GetPropertySingleValueValue("StoreyHeight", true);

            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("Storey Height", true);
            }
            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("FloorHeight", true);
            }
            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("Floor Height", true);
            }

            if (value == DEFAULT_STRING)
            {
                return(DEFAULT_NUMERIC);
            }
            else
            {
                //check it is a number and then format it
                double dblvalue = 0;
                if (double.TryParse(value, out dblvalue))
                {
                    return(string.Format("{0}", dblvalue));
                }
            }

            return(DEFAULT_NUMERIC);
        }
        /// <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);
        }
        private void FillPropertySetsValues(COBieDataPropertySetValues allPropertyValues, IfcTypeObject type, COBieTypeRow typeRow)
        {
            //get related object properties to extract from if main way fails
            allPropertyValues.SetAllPropertyValues(type, "Pset_Asset");
            typeRow.AssetType = GetAssetType(type, allPropertyValues);
            allPropertyValues.SetAllPropertyValues(type, "Pset_ManufacturersTypeInformation");
            string manufacturer = allPropertyValues.GetPropertySingleValueValue("Manufacturer", false);

            typeRow.Manufacturer = ((manufacturer == DEFAULT_STRING) || (!IsEmailAddress(manufacturer))) ? Constants.DEFAULT_EMAIL : manufacturer;

            typeRow.ModelNumber = GetModelNumber(type, allPropertyValues);


            allPropertyValues.SetAllPropertyValues(type, new List <string>(new string[] { "COBie_Warranty", "Pset_Warranty" })); //reset property set name from "Pset_Warranty" to "COBie_Warranty"

            string warrantyDurationPart = allPropertyValues.GetPropertySingleValueValue("WarrantyDurationParts", false);

            typeRow.WarrantyDurationParts = ((warrantyDurationPart == DEFAULT_STRING) || (!IsNumeric(warrantyDurationPart))) ? DEFAULT_NUMERIC : warrantyDurationPart;
            Interval warrantyDuration = GetDurationUnitAndValue(allPropertyValues.GetPropertySingleValue("WarrantyDurationLabor"));

            typeRow.WarrantyDurationLabor = (!IsNumeric(warrantyDuration.Value)) ? DEFAULT_NUMERIC : warrantyDuration.Value;
            typeRow.WarrantyDurationUnit  = (string.IsNullOrEmpty(warrantyDuration.Unit)) ? "Year" : warrantyDuration.Unit;     //redundant column via matrix sheet states set as year

            typeRow.ReplacementCost        = GetReplacementCost(type, allPropertyValues);
            typeRow.WarrantyGuarantorParts = GetWarrantyGuarantorParts(type, allPropertyValues);
            typeRow.WarrantyGuarantorLabor = GetWarrantyGuarantorLabor(type, allPropertyValues);
            typeRow.WarrantyDescription    = GetWarrantyDescription(type, allPropertyValues);


            allPropertyValues.SetAllPropertyValues(type, "Pset_ServiceLife");

            Interval serviceDuration = GetDurationUnitAndValue(allPropertyValues.GetPropertySingleValue("ServiceLifeDuration"));

            typeRow.ExpectedLife = GetExpectedLife(type, serviceDuration, allPropertyValues);
            typeRow.DurationUnit = serviceDuration.Unit;

            allPropertyValues.SetAllPropertyValues(type, new List <string>(new string[] { "COBie_Specification", "Pset_Specification" }));//changed from "Pset_Specification" via v16 matrix sheet

            typeRow.Shape    = allPropertyValues.GetPropertySingleValueValue("Shape", false);
            typeRow.Size     = allPropertyValues.GetPropertySingleValueValue("Size", false);
            typeRow.Finish   = allPropertyValues.GetPropertySingleValueValue("Finish", false);
            typeRow.Grade    = allPropertyValues.GetPropertySingleValueValue("Grade", false);
            typeRow.Material = allPropertyValues.GetPropertySingleValueValue("Material", false);
            typeRow.Features = allPropertyValues.GetPropertySingleValueValue("Features", false);

            typeRow.NominalLength             = GetNominalLength(type, allPropertyValues);
            typeRow.NominalWidth              = GetNominalWidth(type, allPropertyValues);
            typeRow.NominalHeight             = GetNominalHeight(type, allPropertyValues);
            typeRow.ModelReference            = GetModelReference(type, allPropertyValues);
            typeRow.Color                     = GetColour(type, allPropertyValues);
            typeRow.Constituents              = GetConstituents(type, allPropertyValues);
            typeRow.AccessibilityPerformance  = GetAccessibilityPerformance(type, allPropertyValues);
            typeRow.CodePerformance           = GetCodePerformance(type, allPropertyValues);
            typeRow.SustainabilityPerformance = GetSustainabilityPerformance(type, allPropertyValues);
        }
        /// <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);
        }
        /// <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);
        }
        /// <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);
        }
        /// <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);
        }
        /// <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);
        }
        /// <summary>
        /// Get space usable height
        /// </summary>
        /// <param name="ifcSpace">IfcSpace 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 GetUsableHeight(IfcSpace ifcSpace, COBieDataPropertySetValues allPropertyValues)
        {
            IfcLengthMeasure usableHt = ifcSpace.GetHeight();

            if (usableHt != null)
            {
                return(((double)usableHt).ToString("F3"));
            }

            //Fall back to properties
            //get the property single values for this ifcSpace
            if (allPropertyValues.CurrentObject != ifcSpace)
            {
                allPropertyValues.SetAllPropertyValues(ifcSpace);
            }

            //try and find it in the attached properties of the ifcSpace
            string value = allPropertyValues.GetPropertySingleValueValue("UsableHeight", true);

            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("FinishCeiling", true);
            }
            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("FinishCeilingHeight", true);
            }
            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("Height", true);
            }

            if (value == DEFAULT_STRING)
            {
                return(DEFAULT_NUMERIC);
            }
            else
            {
                return(value);
            }
        }
        /// <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);
        }
        /// <summary>
        /// Get space room tag
        /// </summary>
        /// <param name="ifcSpace">IfcSpace 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 GetRoomTag(IfcSpace ifcSpace, COBieDataPropertySetValues allPropertyValues)
        {
            //if (!string.IsNullOrEmpty(ifcSpace.Name)) return ifcSpace.Name;

            string value = ""; // GetSpaceDescription(ifcSpace);

            if (allPropertyValues.CurrentObject != ifcSpace)
            {
                allPropertyValues.SetAllPropertyValues(ifcSpace);
            }
            //try and find it in the attached properties of the ifcSpace
            value = allPropertyValues.GetPropertySingleValueValue("RoomTag", true);
            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("Tag", true);
            }
            if (value == DEFAULT_STRING)
            {
                value = allPropertyValues.GetPropertySingleValueValue("Room_Tag", true);
            }
            return(value);
        }
        /// <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));
        }
        /// <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);
        }
Beispiel #17
0
        /// <summary>
        /// Get the Asset Type from the property set property. If nothing found then default to Moveable/Fixed decided on IfcObjectType
        /// </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)
        {
            allPropertyValues.SetAllPropertyValues(ifcTypeObject, "COBie_Asset");
            string value = allPropertyValues.GetPropertyValue("AssetType", false);

            if (value == DEFAULT_STRING)
            {
                allPropertyValues.SetAllPropertyValues(ifcTypeObject, "Pset_Asset");
                value = allPropertyValues.GetPropertySingleValueValue("AssetAccountingType", false);
            }

            if (value == DEFAULT_STRING)
            {
                if (ifcTypeObject is IfcFurnitureType)
                {
                    value = "Moveable";     // Could be NonFixed in US picklists
                }
                else
                {
                    value = "Fixed";
                }
            }
            return(value);
        }
        /// <summary>
        /// Fill sheet rows for Space sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieSpaceRow> Fill()
        {
#if DEBUG
            Stopwatch timer = new Stopwatch();
            timer.Start();
#endif
            ProgressIndicator.ReportMessage("Starting Spaces...");

            //create new sheet
            COBieSheet <COBieSpaceRow> spaces = new COBieSheet <COBieSpaceRow>(Constants.WORKSHEET_SPACE);

            // get all IfcBuildingStory objects from IFC file
            List <IfcSpace> ifcSpaces = Model.Instances.OfType <IfcSpace>().OrderBy(ifcSpace => ifcSpace.Name, new CompareIfcLabel()).ToList();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);
            attributeBuilder.InitialiseAttributes(ref _attributes);

            if (Context.DepartmentsUsedAsZones)
            {
                attributeBuilder.ExcludeAttributePropertyNames.Add("Department"); //remove the department property from selection
            }
            //set up filters on COBieDataPropertySetValues
            attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Space.AttributesEqualTo);
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Space.AttributesContain);
            attributeBuilder.ExcludeAttributePropertySetNames.AddRange(Context.Exclude.Space.PropertySetsEqualTo);
            attributeBuilder.RowParameters["Sheet"] = "Space";

            ProgressIndicator.Initialise("Creating Spaces", ifcSpaces.Count());

            foreach (IfcSpace ifcSpace in ifcSpaces)
            {
                ProgressIndicator.IncrementAndUpdate();

                COBieSpaceRow space = new COBieSpaceRow(spaces);
                //set allPropertyValues to this element
                allPropertyValues.SetAllPropertyValues(ifcSpace); //set the internal filtered IfcPropertySingleValues List in allPropertyValues

                space.Name = ifcSpace.Name;

                string createBy = allPropertyValues.GetPropertySingleValueValue("COBieCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                space.CreatedBy = ValidateString(createBy) ? createBy : GetTelecomEmailAddress(ifcSpace.OwnerHistory);
                string createdOn = allPropertyValues.GetPropertySingleValueValue("COBieCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                space.CreatedOn = ValidateString(createdOn) ? createdOn : GetCreatedOnDateAsFmtString(ifcSpace.OwnerHistory);

                space.Category = GetCategory(ifcSpace);

                space.FloorName = ((ifcSpace.SpatialStructuralElementParent != null) && (!string.IsNullOrEmpty(ifcSpace.SpatialStructuralElementParent.Name))) ? ifcSpace.SpatialStructuralElementParent.Name.ToString() : DEFAULT_STRING;
                string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false); //support for COBie Toolkit for Autodesk Revit
                space.Description = ValidateString(description) ? description : GetSpaceDescription(ifcSpace);
                string extSystem = allPropertyValues.GetPropertySingleValueValue("COBieExtSystem", false);     //support for COBie Toolkit for Autodesk Revit
                space.ExtSystem     = ValidateString(extSystem) ? extSystem : GetExternalSystem(ifcSpace);
                space.ExtObject     = ifcSpace.GetType().Name;
                space.ExtIdentifier = ifcSpace.GlobalId;
                space.RoomTag       = GetRoomTag(ifcSpace, allPropertyValues);

                //Do Unit Values
                space.UsableHeight = GetUsableHeight(ifcSpace, allPropertyValues);
                space.GrossArea    = GetGrossFloorArea(ifcSpace, allPropertyValues);
                space.NetArea      = GetNetArea(ifcSpace, allPropertyValues);

                spaces.AddRow(space);

                //----------fill in the attribute information for spaces-----------

                //fill in the attribute information
                attributeBuilder.RowParameters["Name"]      = space.Name;
                attributeBuilder.RowParameters["CreatedBy"] = space.CreatedBy;
                attributeBuilder.RowParameters["CreatedOn"] = space.CreatedOn;
                attributeBuilder.RowParameters["ExtSystem"] = space.ExtSystem;
                attributeBuilder.PopulateAttributesRows(ifcSpace); //fill attribute sheet rows//pass data from this sheet info as Dictionary
            }

            spaces.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();
#if DEBUG
            timer.Stop();
            Console.WriteLine(String.Format("Time to generate Spaces data = {0} seconds", timer.Elapsed.TotalSeconds.ToString("F3")));
#endif
            return(spaces);
        }
        /// <summary>
        /// Fill sheet rows for Component sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieComponentRow> Fill()
        {
#if DEBUG
            Stopwatch timer = new Stopwatch();
            timer.Start();
#endif
            ProgressIndicator.ReportMessage("Starting Components...");
            //Create new sheet
            COBieSheet <COBieComponentRow> components = new COBieSheet <COBieComponentRow>(Constants.WORKSHEET_COMPONENT);



            IEnumerable <IfcRelAggregates> relAggregates = Model.FederatedInstances.OfType <IfcRelAggregates>();
            IEnumerable <IfcRelContainedInSpatialStructure> relSpatial = Model.FederatedInstances.OfType <IfcRelContainedInSpatialStructure>();

            IEnumerable <IfcObject> ifcElements = ((from x in relAggregates
                                                    from y in x.RelatedObjects
                                                    where !Context.Exclude.ObjectType.Component.Contains(y.GetType())
                                                    select y).Union(from x in relSpatial
                                                                    from y in x.RelatedElements
                                                                    where !Context.Exclude.ObjectType.Component.Contains(y.GetType())
                                                                    select y)).OfType <IfcObject>(); //.GroupBy(el => el.Name).Select(g => g.First())//.Distinct().ToList();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues();         //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);
            attributeBuilder.InitialiseAttributes(ref _attributes);
            //set up filters on COBieDataPropertySetValues for the SetAttributes only
            attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Component.AttributesEqualTo);         //we do not want listed properties for the attribute sheet so filter them out
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Component.AttributesContain); //we do not want listed properties for the attribute sheet so filter them out
            attributeBuilder.RowParameters["Sheet"] = "Component";


            ProgressIndicator.Initialise("Creating Components", ifcElements.Count());

            foreach (var obj in ifcElements)
            {
                ProgressIndicator.IncrementAndUpdate();

                COBieComponentRow component = new COBieComponentRow(components);

                IfcElement el = obj as IfcElement;
                if (el == null)
                {
                    continue;
                }
                string name = el.Name.ToString();
                if (string.IsNullOrEmpty(name))
                {
                    name = "Name Unknown " + UnknownCount.ToString();
                    UnknownCount++;
                }
                //set allPropertyValues to this element
                allPropertyValues.SetAllPropertyValues(el); //set the internal filtered IfcPropertySingleValues List in allPropertyValues
                component.Name = name;

                string createBy = allPropertyValues.GetPropertySingleValueValue("COBieCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                component.CreatedBy = ValidateString(createBy) ? createBy : GetTelecomEmailAddress(el.OwnerHistory);
                string createdOn = allPropertyValues.GetPropertySingleValueValue("COBieCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                component.CreatedOn = ValidateString(createdOn) ?  createdOn : GetCreatedOnDateAsFmtString(el.OwnerHistory);

                component.TypeName = GetTypeName(el);
                component.Space    = COBieHelpers.GetComponentRelatedSpace(el, Model, SpaceBoundingBoxInfo, Context);
                string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false); //support for COBie Toolkit for Autodesk Revit
                component.Description = ValidateString(description) ? description : GetComponentDescription(el);
                string extSystem = allPropertyValues.GetPropertySingleValueValue("COBieExtSystem", false);     //support for COBie Toolkit for Autodesk Revit
                component.ExtSystem     = ValidateString(extSystem) ? extSystem : GetExternalSystem(el);
                component.ExtObject     = el.GetType().Name;
                component.ExtIdentifier = el.GlobalId;

                //set from PropertySingleValues filtered via candidateProperties
                //set the internal filtered IfcPropertySingleValues List in allPropertyValues to this element set above
                component.SerialNumber      = allPropertyValues.GetPropertySingleValueValue("SerialNumber", false);
                component.InstallationDate  = GetDateFromProperty(allPropertyValues, "InstallationDate");
                component.WarrantyStartDate = GetDateFromProperty(allPropertyValues, "WarrantyStartDate");
                component.TagNumber         = allPropertyValues.GetPropertySingleValueValue("TagNumber", false);
                component.BarCode           = allPropertyValues.GetPropertySingleValueValue("BarCode", false);
                component.AssetIdentifier   = allPropertyValues.GetPropertySingleValueValue("AssetIdentifier", false);

                components.AddRow(component);

                //fill in the attribute information
                attributeBuilder.RowParameters["Name"]      = component.Name;
                attributeBuilder.RowParameters["CreatedBy"] = component.CreatedBy;
                attributeBuilder.RowParameters["CreatedOn"] = component.CreatedOn;
                attributeBuilder.RowParameters["ExtSystem"] = component.ExtSystem;
                attributeBuilder.PopulateAttributesRows(el); //fill attribute sheet rows
            }

            components.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();
#if DEBUG
            timer.Stop();
            Console.WriteLine("Time to generate Component data = {0} seconds", timer.Elapsed.TotalSeconds.ToString("F3"));
#endif


            return(components);
        }
Beispiel #20
0
        /// <summary>
        /// Fill sheet rows for Zone sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieZoneRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Zones...");

            //Create new sheet
            COBieSheet <COBieZoneRow> zones = new COBieSheet <COBieZoneRow>(Constants.WORKSHEET_ZONE);


            // get all IfcBuildingStory objects from IFC file
            IEnumerable <IfcZone> ifcZones = Model.FederatedInstances.OfType <IfcZone>();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);

            attributeBuilder.InitialiseAttributes(ref _attributes);

            //list of attributes to exclude form attribute sheet
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Zone.AttributesContain);
            attributeBuilder.RowParameters["Sheet"] = "Zone";

            //Also check to see if we have any zones within the spaces
            IEnumerable <IfcSpace> ifcSpaces = Model.FederatedInstances.OfType <IfcSpace>();//.OrderBy(ifcSpace => ifcSpace.Name, new CompareIfcLabel());

            ProgressIndicator.Initialise("Creating Zones", ifcZones.Count() + ifcSpaces.Count());

            foreach (IfcZone zn in ifcZones)
            {
                ProgressIndicator.IncrementAndUpdate();
                // create zone for each space found
                Dictionary <String, COBieZoneRow> ExistingZones = new Dictionary <string, COBieZoneRow>();
                IEnumerable <IfcSpace>            spaces        = (zn.IsGroupedBy == null) ? Enumerable.Empty <IfcSpace>() : zn.IsGroupedBy.RelatedObjects.OfType <IfcSpace>();
                foreach (IfcSpace sp in spaces)
                {
                    COBieZoneRow zone;
                    if (ExistingZones.ContainsKey(zn.Name.ToString()))
                    {
                        zone             = ExistingZones[zn.Name.ToString()];
                        zone.SpaceNames += "," + sp.Name.ToString();
                    }
                    else
                    {
                        zone = new COBieZoneRow(zones);
                        ExistingZones[zn.Name.ToString()] = zone;

                        //set allPropertyValues to this element
                        allPropertyValues.SetAllPropertyValues(zn); //set the internal filtered IfcPropertySingleValues List in allPropertyValues

                        zone.Name = zn.Name.ToString();

                        string createBy = allPropertyValues.GetPropertySingleValueValue("COBieCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                        zone.CreatedBy = ValidateString(createBy) ? createBy : GetTelecomEmailAddress(zn.OwnerHistory);
                        string createdOn = allPropertyValues.GetPropertySingleValueValue("COBieCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                        zone.CreatedOn = ValidateString(createdOn) ? createdOn : GetCreatedOnDateAsFmtString(zn.OwnerHistory);

                        zone.Category = GetCategory(zn);

                        zone.SpaceNames = sp.Name;

                        string extSystem = allPropertyValues.GetPropertySingleValueValue("COBieExtSystem", false);//support for COBie Toolkit for Autodesk Revit
                        zone.ExtSystem     = ValidateString(extSystem) ? extSystem : GetExternalSystem(zn);
                        zone.ExtObject     = zn.GetType().Name;
                        zone.ExtIdentifier = zn.GlobalId;
                        string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false);//support for COBie Toolkit for Autodesk Revit
                        if (ValidateString(extSystem))
                        {
                            zone.Description = extSystem;
                        }
                        else
                        {
                            zone.Description = (string.IsNullOrEmpty(zn.Description)) ? zn.Name.ToString() : zn.Description.ToString(); //if IsNullOrEmpty on Description then output Name
                        }
                        zones.AddRow(zone);

                        //fill in the attribute information
                        attributeBuilder.RowParameters["Name"]      = zone.Name;
                        attributeBuilder.RowParameters["CreatedBy"] = zone.CreatedBy;
                        attributeBuilder.RowParameters["CreatedOn"] = zone.CreatedOn;
                        attributeBuilder.RowParameters["ExtSystem"] = zone.ExtSystem;
                        attributeBuilder.PopulateAttributesRows(zn); //fill attribute sheet rows//pass data from this sheet info as Dictionary
                    }
                }
            }

            COBieDataPropertySetValues allSpacePropertyValues = new COBieDataPropertySetValues(); //get all property sets and associated properties in one go

            Dictionary <String, COBieZoneRow> myExistingZones = new Dictionary <string, COBieZoneRow>();

            foreach (IfcSpace sp in ifcSpaces)
            {
                ProgressIndicator.IncrementAndUpdate();
                allSpacePropertyValues.SetAllPropertyValues(sp); //set the space as the current object for the properties get glass

                IEnumerable <IfcPropertySingleValue> spProperties = Enumerable.Empty <IfcPropertySingleValue>();
                foreach (KeyValuePair <IfcPropertySet, IEnumerable <IfcSimpleProperty> > item in allSpacePropertyValues.MapPsetToProps)
                {
                    IfcPropertySet pset = item.Key;
                    spProperties = item.Value.Where(p => p.Name.ToString().Contains("ZoneName")).OfType <IfcPropertySingleValue>();


                    //if we have no ifcZones or "ZoneName" properties, and the DepartmentsUsedAsZones flag is true then list departments as zones
                    if ((!spProperties.Any()) && (!ifcZones.Any()) && (Context.DepartmentsUsedAsZones == true))
                    {
                        spProperties = item.Value.Where(p => p.Name == "Department").OfType <IfcPropertySingleValue>();
                    }

                    foreach (IfcPropertySingleValue spProp in spProperties)
                    {
                        COBieZoneRow zone;
                        if (myExistingZones.ContainsKey(spProp.NominalValue.ToString()))
                        {
                            zone             = myExistingZones[spProp.NominalValue.ToString()];
                            zone.SpaceNames += "," + sp.Name;
                        }
                        else
                        {
                            zone      = new COBieZoneRow(zones);
                            zone.Name = spProp.NominalValue.ToString();
                            myExistingZones[spProp.NominalValue.ToString()] = zone;

                            zone.CreatedBy = GetTelecomEmailAddress(sp.OwnerHistory);
                            zone.CreatedOn = GetCreatedOnDateAsFmtString(sp.OwnerHistory);

                            zone.Category   = spProp.Name;
                            zone.SpaceNames = sp.Name;

                            zone.ExtSystem     = GetExternalSystem(pset);
                            zone.ExtObject     = spProp.GetType().Name;
                            zone.ExtIdentifier = pset.GlobalId.ToString(); //IfcPropertySingleValue has no GlobalId so set to the holding IfcPropertySet

                            zone.Description = (string.IsNullOrEmpty(spProp.NominalValue.ToString())) ? DEFAULT_STRING : spProp.NominalValue.ToString();;

                            zones.AddRow(zone);
                        }
                    }
                }
                //spProperties = spProperties.OrderBy(p => p.Name.ToString(), new CompareString()); //consolidate test, Concat as looping spaces then sort then dump to COBieZoneRow foreach
            }

            zones.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();

            return(zones);
        }
Beispiel #21
0
        /// <summary>
        /// Fill sheet rows for Floor sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieFloorRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Floors...");

            //create new sheet
            COBieSheet <COBieFloorRow> floors = new COBieSheet <COBieFloorRow>(Constants.WORKSHEET_FLOOR);

            // get all IfcBuildingStory objects from IFC file
            IEnumerable <IfcBuildingStorey> buildingStories = Model.Instances.OfType <IfcBuildingStorey>();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);

            attributeBuilder.InitialiseAttributes(ref _attributes);


            //IfcClassification ifcClassification = Model.Instances.OfType<IfcClassification>().FirstOrDefault();
            //list of attributes to exclude form attribute sheet

            //set up filters on COBieDataPropertySetValues for the SetAttributes only
            attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Floor.AttributesEqualTo);
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Floor.AttributesContain);
            attributeBuilder.RowParameters["Sheet"] = "Floor";



            ProgressIndicator.Initialise("Creating Floors", buildingStories.Count());

            foreach (IfcBuildingStorey ifcBuildingStorey in buildingStories)
            {
                ProgressIndicator.IncrementAndUpdate();

                COBieFloorRow floor = new COBieFloorRow(floors);
                string        name  = ifcBuildingStorey.Name;
                if (string.IsNullOrEmpty(ifcBuildingStorey.Name))
                {
                    ifcBuildingStorey.Name = "Name Unknown " + UnknownCount.ToString();
                    UnknownCount++;
                }

                //set allPropertyValues to this element
                allPropertyValues.SetAllPropertyValues(ifcBuildingStorey); //set the internal filtered IfcPropertySingleValues List in allPropertyValues


                floor.Name = name;

                string createBy = allPropertyValues.GetPropertySingleValueValue("COBieCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                floor.CreatedBy = ValidateString(createBy) ? createBy : GetTelecomEmailAddress(ifcBuildingStorey.OwnerHistory);
                string createdOn = allPropertyValues.GetPropertySingleValueValue("COBieCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                floor.CreatedOn = ValidateString(createdOn) ? createdOn : GetCreatedOnDateAsFmtString(ifcBuildingStorey.OwnerHistory);

                floor.Category = GetCategory(ifcBuildingStorey);

                string extSystem = allPropertyValues.GetPropertySingleValueValue("COBieExtSystem", false);//support for COBie Toolkit for Autodesk Revit
                floor.ExtSystem     = ValidateString(extSystem) ? extSystem : GetExternalSystem(ifcBuildingStorey);
                floor.ExtObject     = ifcBuildingStorey.GetType().Name;
                floor.ExtIdentifier = ifcBuildingStorey.GlobalId;
                string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false);//support for COBie Toolkit for Autodesk Revit
                floor.Description = ValidateString(description) ? description : GetFloorDescription(ifcBuildingStorey);
                floor.Elevation   = (string.IsNullOrEmpty(ifcBuildingStorey.Elevation.ToString())) ? DEFAULT_NUMERIC : string.Format("{0}", (double)ifcBuildingStorey.Elevation);

                floor.Height = GetFloorHeight(ifcBuildingStorey, allPropertyValues);

                floors.AddRow(floor);

                //fill in the attribute information
                attributeBuilder.RowParameters["Name"]      = floor.Name;
                attributeBuilder.RowParameters["CreatedBy"] = floor.CreatedBy;
                attributeBuilder.RowParameters["CreatedOn"] = floor.CreatedOn;
                attributeBuilder.RowParameters["ExtSystem"] = floor.ExtSystem;
                attributeBuilder.PopulateAttributesRows(ifcBuildingStorey); //fill attribute sheet rows//pass data from this sheet info as Dictionary
            }

            floors.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();

            return(floors);
        }
        /// <summary>
        /// Fill sheet rows for Type sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieTypeRow> Fill()
        {
#if DEBUG
            Stopwatch timer = new Stopwatch();
            timer.Start();
#endif
            ProgressIndicator.ReportMessage("Starting Types...");

            var ifcProject = Model.Instances.FirstOrDefault <IIfcProject>();
            Debug.Assert(ifcProject != null);

            // Create new Sheet
            COBieSheet <COBieTypeRow> types = new COBieSheet <COBieTypeRow>(Constants.WORKSHEET_TYPE);

            //group the types by name as we need to filter duplicate items in for each loop
            IEnumerable <IfcTypeObject> ifcTypeObjects = Model.FederatedInstances.OfType <IfcTypeObject>()
                                                         .Select(type => type)
                                                         .Where(type => !Context.Exclude.ObjectType.Types.Contains(type.GetType()))
                                                         .GroupBy(type => type.Name).SelectMany(g => g);//.Distinct()



            //set up property set helper class
            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);
            attributeBuilder.InitialiseAttributes(ref _attributes);
            attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Types.AttributesEqualTo);         //we do not want for the attribute sheet so filter them out
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Types.AttributesContain); //we do not want for the attribute sheet so filter them out
            attributeBuilder.ExcludeAttributePropertySetNames.AddRange(Context.Exclude.Types.PropertySetsEqualTo);    //exclude the property set from selection of values
            attributeBuilder.RowParameters["Sheet"] = "Type";

            ProgressIndicator.Initialise("Creating Types", ifcTypeObjects.Count());
            //COBieTypeRow lastRow = null;
            foreach (IfcTypeObject type in ifcTypeObjects)
            {
                ProgressIndicator.IncrementAndUpdate();


                COBieTypeRow typeRow = new COBieTypeRow(types);

                // TODO: Investigate centralising this common code.
                string name = type.Name;
                if (string.IsNullOrEmpty(type.Name))
                {
                    name = "Name Unknown " + UnknownCount.ToString();
                    UnknownCount++;
                }

                //set allPropertyValues to this element
                allPropertyValues.SetAllPropertyValues(type); //set the internal filtered IfcPropertySingleValues List in allPropertyValues

                typeRow.Name = name;
                string create_By = allPropertyValues.GetPropertySingleValueValue("COBieTypeCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                typeRow.CreatedBy = ValidateString(create_By) ? create_By : GetTelecomEmailAddress(type.OwnerHistory);
                string created_On = allPropertyValues.GetPropertySingleValueValue("COBieTypeCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                typeRow.CreatedOn = ValidateString(created_On) ? created_On : GetCreatedOnDateAsFmtString(type.OwnerHistory);
                typeRow.Category  = GetCategory(allPropertyValues);
                string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false);//support for COBie Toolkit for Autodesk Revit
                typeRow.Description = ValidateString(description) ? description : GetTypeObjDescription(type);

                string ext_System = allPropertyValues.GetPropertySingleValueValue("COBieTypeExtSystem", false);//support for COBie Toolkit for Autodesk Revit
                typeRow.ExtSystem     = ValidateString(ext_System) ? ext_System : GetExternalSystem(type);
                typeRow.ExtObject     = type.GetType().Name;
                typeRow.ExtIdentifier = type.GlobalId;



                FillPropertySetsValues(allPropertyValues, type, typeRow);
                //not duplicate so add to sheet
                //if (CheckForDuplicateRow(lastRow, typeRow))
                //{
                string rowhash = typeRow.RowHashValue;
                if (RowHashs.ContainsKey(rowhash))
                {
                    continue;
                }
                else
                {
                    types.AddRow(typeRow);
                    RowHashs.Add(rowhash, true);
                }

                //lastRow = typeRow; //save this row to test on next loop
                //}
                // Provide Attribute sheet with our context
                //fill in the attribute information
                attributeBuilder.RowParameters["Name"]      = typeRow.Name;
                attributeBuilder.RowParameters["CreatedBy"] = typeRow.CreatedBy;
                attributeBuilder.RowParameters["CreatedOn"] = typeRow.CreatedOn;
                attributeBuilder.RowParameters["ExtSystem"] = typeRow.ExtSystem;
                attributeBuilder.PopulateAttributesRows(type); //fill attribute sheet rows
            }
            ProgressIndicator.Finalise();
            //--------------Loop all IfcMaterialLayerSet-----------------------------
            ProgressIndicator.ReportMessage("Starting MaterialLayerSets...");
            IEnumerable <IfcMaterialLayerSet> ifcMaterialLayerSets = Model.FederatedInstances.OfType <IfcMaterialLayerSet>();
            ChildNamesList rowHolderChildNames      = new ChildNamesList();
            ChildNamesList rowHolderLayerChildNames = new ChildNamesList();

            string createdBy = DEFAULT_STRING, createdOn = DEFAULT_STRING, extSystem = DEFAULT_STRING;
            ProgressIndicator.Initialise("Creating MaterialLayerSets", ifcMaterialLayerSets.Count());

            foreach (IfcMaterialLayerSet ifcMaterialLayerSet in ifcMaterialLayerSets)
            {
                ProgressIndicator.IncrementAndUpdate();
                //Material layer has no owner history, so lets take the owner history from IfcRelAssociatesMaterial.RelatingMaterial -> (IfcMaterialLayerSetUsage.ForLayerSet -> IfcMaterialLayerSet) || IfcMaterialLayerSet || IfcMaterialLayer as it is a IfcMaterialSelect
                IfcOwnerHistory ifcOwnerHistory = GetMaterialOwnerHistory(ifcMaterialLayerSet);
                if (ifcOwnerHistory != null)
                {
                    createdBy = GetTelecomEmailAddress(ifcOwnerHistory);
                    createdOn = GetCreatedOnDateAsFmtString(ifcOwnerHistory);
                    extSystem = GetExternalSystem(ifcOwnerHistory);
                }
                else //default to the project as we failed to find a IfcRoot object to extract it from
                {
                    createdBy = GetTelecomEmailAddress(ifcProject.OwnerHistory);
                    createdOn = GetCreatedOnDateAsFmtString(ifcProject.OwnerHistory);
                    extSystem = GetExternalSystem(ifcProject.OwnerHistory);
                }
                //add materialLayerSet name to rows
                COBieTypeRow matSetRow = new COBieTypeRow(types);
                matSetRow.Name      = (string.IsNullOrEmpty(ifcMaterialLayerSet.LayerSetName)) ? DEFAULT_STRING : ifcMaterialLayerSet.LayerSetName.ToString();
                matSetRow.CreatedBy = createdBy;
                matSetRow.CreatedOn = createdOn;
                matSetRow.ExtSystem = extSystem;
                matSetRow.ExtObject = ifcMaterialLayerSet.GetType().Name;
                matSetRow.AssetType = "Fixed";
                types.AddRow(matSetRow);

                //loop the materials within the material layer set
                foreach (IfcMaterialLayer ifcMaterialLayer in ifcMaterialLayerSet.MaterialLayers)
                {
                    if ((ifcMaterialLayer.Material != null) &&
                        (!string.IsNullOrEmpty(ifcMaterialLayer.Material.Name))
                        )
                    {
                        string name      = ifcMaterialLayer.Material.Name.ToString().Trim();
                        double thickness = ifcMaterialLayer.LayerThickness;
                        string keyName   = name + " (" + thickness.ToString(CultureInfo.InvariantCulture) + ")";
                        if (!rowHolderLayerChildNames.Contains(keyName.ToLower())) //check we do not already have it
                        {
                            COBieTypeRow matRow = new COBieTypeRow(types);

                            matRow.Name         = keyName;
                            matRow.CreatedBy    = createdBy;
                            matRow.CreatedOn    = createdOn;
                            matRow.ExtSystem    = extSystem;
                            matRow.ExtObject    = ifcMaterialLayer.GetType().Name;
                            matRow.AssetType    = "Fixed";
                            matRow.NominalWidth = thickness.ToString();

                            rowHolderLayerChildNames.Add(keyName.ToLower());

                            //we also don't want to repeat on the IfcMaterial loop below
                            if (!rowHolderChildNames.Contains(name.ToLower()))
                            {
                                rowHolderChildNames.Add(name.ToLower());
                            }

                            types.AddRow(matRow);
                        }
                    }
                }
            }
            ProgressIndicator.Finalise();
            //--------Loop Materials in case they are not in a layer Set-----
            ProgressIndicator.ReportMessage("Starting Materials...");

            IEnumerable <IfcMaterial> ifcMaterials = Model.FederatedInstances.OfType <IfcMaterial>();
            ProgressIndicator.Initialise("Creating Materials", ifcMaterials.Count());
            foreach (IfcMaterial ifcMaterial in ifcMaterials)
            {
                ProgressIndicator.IncrementAndUpdate();
                string name = ifcMaterial.Name.ToString().Trim();
                if (!string.IsNullOrEmpty(ifcMaterial.Name))
                {
                    if (!rowHolderChildNames.Contains(name.ToLower())) //check we do not already have it
                    {
                        COBieTypeRow matRow = new COBieTypeRow(types);

                        matRow.Name      = name;
                        matRow.CreatedBy = createdBy; //no way of extraction on material, if no material layer set, so use last found in Layer Set loop
                        matRow.CreatedOn = createdOn; //ditto
                        matRow.ExtSystem = extSystem; //ditto
                        matRow.ExtObject = ifcMaterial.GetType().Name;
                        matRow.AssetType = "Fixed";

                        types.AddRow(matRow);
                    }

                    rowHolderChildNames.Add(name.ToLower());
                }
            }

            types.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();

#if DEBUG
            timer.Stop();
            Console.WriteLine(String.Format("Time to generate Type data = {0} seconds", timer.Elapsed.TotalSeconds.ToString("F3")));
#endif
            return(types);
        }
Beispiel #23
0
        /// <summary>
        /// Fill sheet rows for Spare sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieSpareRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Spares...");
            //Create new sheet
            COBieSheet <COBieSpareRow> spares = new COBieSheet <COBieSpareRow>(Constants.WORKSHEET_SPARE);
            // get all IfcBuildingStory objects from IFC file
            IEnumerable <IfcConstructionProductResource> ifcConstructionProductResources = Model.FederatedInstances.OfType <IfcConstructionProductResource>();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);

            attributeBuilder.InitialiseAttributes(ref _attributes);
            attributeBuilder.RowParameters["Sheet"] = "Spare";
            //set up filters on COBieDataPropertySetValues
            attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Spare.AttributesEqualTo);
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Spare.AttributesContain);


            //IfcTypeObject typeObject = Model.FederatedInstances.OfType<IfcTypeObject>().FirstOrDefault();

            ProgressIndicator.Initialise("Creating Spares", ifcConstructionProductResources.Count());

            foreach (IfcConstructionProductResource ifcConstructionProductResource in ifcConstructionProductResources)
            {
                ProgressIndicator.IncrementAndUpdate();

                COBieSpareRow spare = new COBieSpareRow(spares);
                //set allPropertyValues to this element
                allPropertyValues.SetAllPropertyValues(ifcConstructionProductResource); //set the internal filtered IfcPropertySingleValues List in allPropertyValues

                spare.Name = (string.IsNullOrEmpty(ifcConstructionProductResource.Name)) ? "" : ifcConstructionProductResource.Name.ToString();

                string createBy = allPropertyValues.GetPropertySingleValueValue("COBieCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                spare.CreatedBy = ValidateString(createBy) ? createBy : GetTelecomEmailAddress(ifcConstructionProductResource.OwnerHistory);
                string createdOn = allPropertyValues.GetPropertySingleValueValue("COBieCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                spare.CreatedOn = ValidateString(createdOn) ? createdOn : GetCreatedOnDateAsFmtString(ifcConstructionProductResource.OwnerHistory);

                spare.Category = GetCategory(ifcConstructionProductResource);

                spare.TypeName = GetObjectType(ifcConstructionProductResource);

                string extSystem = allPropertyValues.GetPropertySingleValueValue("COBieExtSystem", false);//support for COBie Toolkit for Autodesk Revit
                spare.ExtSystem     = ValidateString(extSystem) ? extSystem : GetExternalSystem(ifcConstructionProductResource);
                spare.ExtObject     = ifcConstructionProductResource.GetType().Name;
                spare.ExtIdentifier = ifcConstructionProductResource.GlobalId;
                string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false);//support for COBie Toolkit for Autodesk Revit
                if (ValidateString(description))
                {
                    spare.Description = description;
                }
                else
                {
                    spare.Description = (ifcConstructionProductResource == null) ? "" : ifcConstructionProductResource.Description.ToString();
                }

                //get information from Pset_Spare_COBie property set
                var ifcPropertySet = ifcConstructionProductResource.GetPropertySet("Pset_Spare_COBie");
                if (ifcPropertySet != null)
                {
                    var ifcPropertySingleValue = ifcPropertySet.HasProperties.OfType <IIfcPropertySingleValue>().FirstOrDefault(p => p.Name == "Suppliers");
                    spare.Suppliers = ((ifcPropertySingleValue != null) && (!string.IsNullOrEmpty(ifcPropertySingleValue.NominalValue.ToString()))) ? ifcPropertySingleValue.NominalValue.ToString() : DEFAULT_STRING;

                    ifcPropertySingleValue = ifcPropertySet.HasProperties.OfType <IIfcPropertySingleValue>().FirstOrDefault(p => p.Name == "SetNumber");
                    spare.SetNumber        = ((ifcPropertySingleValue != null) && (!string.IsNullOrEmpty(ifcPropertySingleValue.NominalValue.ToString()))) ? ifcPropertySingleValue.NominalValue.ToString() : DEFAULT_STRING;;

                    ifcPropertySingleValue = ifcPropertySet.HasProperties.OfType <IIfcPropertySingleValue>().FirstOrDefault(p => p.Name == "PartNumber");
                    spare.PartNumber       = ((ifcPropertySingleValue != null) && (!string.IsNullOrEmpty(ifcPropertySingleValue.NominalValue.ToString()))) ? ifcPropertySingleValue.NominalValue.ToString() : DEFAULT_STRING;;
                }
                else
                {
                    spare.Suppliers  = DEFAULT_STRING;
                    spare.SetNumber  = DEFAULT_STRING;
                    spare.PartNumber = DEFAULT_STRING;
                }
                if ((spare.Name == DEFAULT_STRING) && (spare.TypeName == DEFAULT_STRING) && (spare.Description == DEFAULT_STRING))
                {
                    continue;
                }
                spares.AddRow(spare);

                //----------fill in the attribute information for spaces-----------

                //fill in the attribute information
                attributeBuilder.RowParameters["Name"]      = spare.Name;
                attributeBuilder.RowParameters["CreatedBy"] = spare.CreatedBy;
                attributeBuilder.RowParameters["CreatedOn"] = spare.CreatedOn;
                attributeBuilder.RowParameters["ExtSystem"] = spare.ExtSystem;
                attributeBuilder.PopulateAttributesRows(ifcConstructionProductResource); //fill attribute sheet rows//pass data from this sheet info as Dictionary
            }

            spares.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();
            return(spares);
        }