Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Fill sheet rows for Facility sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieFacilityRow> Fill()
        {
            ProgressIndicator.ReportMessage("Starting Facilities...");

            //Create new sheet
            var facilities = new COBieSheet <COBieFacilityRow>(Constants.WORKSHEET_FACILITY);

            var ifcProject  = Model.FederatedInstances.OfType <IfcProject>().FirstOrDefault();
            var ifcSite     = Model.FederatedInstances.OfType <IfcSite>().FirstOrDefault();
            var ifcBuilding = Model.FederatedInstances.OfType <IfcBuilding>().FirstOrDefault();

            //get Element Quantity holding area values as used for AreaMeasurement below
            var ifcElementQuantityAreas = Model.FederatedInstances.OfType <IfcElementQuantity>().FirstOrDefault(eq => eq.Quantities.OfType <IfcQuantityArea>().Any());

            var ifcObjectList = new List <IfcObject>();

            if (ifcProject != null)
            {
                ifcObjectList.Add(ifcProject);
            }
            if (ifcSite != null)
            {
                ifcObjectList.Add(ifcSite);
            }
            if (ifcBuilding != null)
            {
                ifcObjectList.Add(ifcBuilding);
            }

            var ifcObjects = ifcObjectList.AsEnumerable();

            if (ifcObjects.Any())
            {
                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
                //set up filters on COBieDataPropertySetValues for the SetAttributes only
                attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Facility.AttributesEqualTo);
                attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Facility.AttributesContain);
                attributeBuilder.RowParameters["Sheet"] = "Facility";

                COBieFacilityRow facility = new COBieFacilityRow(facilities);

                string name = "";
                if ((ifcBuilding != null) && (!string.IsNullOrEmpty(ifcBuilding.Name)))
                {
                    name = ifcBuilding.Name;
                }
                else if ((ifcSite != null) && (!string.IsNullOrEmpty(ifcSite.Name)))
                {
                    name = ifcSite.Name;
                }
                else if ((ifcProject != null) && (!string.IsNullOrEmpty(ifcProject.Name)))
                {
                    name = ifcProject.Name;
                }
                else
                {
                    name = DEFAULT_STRING;
                }

                facility.Name = (string.IsNullOrEmpty(name)) ? "The Facility Name Here" : name;

                var createBy = ifcBuilding.GetPropertySingleNominalValue("Other", "COBieCreatedBy");  //support for COBie Toolkit for Autodesk Revit
                facility.CreatedBy = ((createBy != null) && ValidateString(createBy.ToString())) ? createBy.ToString() : GetTelecomEmailAddress(ifcBuilding.OwnerHistory);
                var createdOn = ifcBuilding.GetPropertySingleNominalValue("Other", "COBieCreatedOn"); //support for COBie Toolkit for Autodesk Revit
                facility.CreatedOn = ((createdOn != null) && ValidateString(createdOn.ToString())) ? createdOn.ToString() : GetCreatedOnDateAsFmtString(ifcBuilding.OwnerHistory);

                facility.Category = GetCategory(ifcBuilding);

                facility.ProjectName = GetFacilityProjectName(ifcProject);
                facility.SiteName    = GetFacilitySiteName(ifcSite);

                facility.LinearUnits  = Context.WorkBookUnits.LengthUnit;
                facility.AreaUnits    = Context.WorkBookUnits.AreaUnit;
                facility.VolumeUnits  = Context.WorkBookUnits.VolumeUnit;
                facility.CurrencyUnit = Context.WorkBookUnits.MoneyUnit;

                string areaMeasurement = (ifcElementQuantityAreas == null) ? DEFAULT_STRING : ifcElementQuantityAreas.MethodOfMeasurement.ToString();

                facility.AreaMeasurement = ((areaMeasurement == DEFAULT_STRING) || (areaMeasurement.ToLower().Contains("bim area"))) ? areaMeasurement : areaMeasurement + " BIM Area";
                facility.ExternalSystem  = GetExternalSystem(ifcBuilding);

                facility.ExternalProjectObject     = "IfcProject";
                facility.ExternalProjectIdentifier = ifcProject.GlobalId;

                facility.ExternalSiteObject     = "IfcSite";
                facility.ExternalSiteIdentifier = (ifcSite != null) ? ifcSite.GlobalId.ToString() : DEFAULT_STRING;

                facility.ExternalFacilityObject     = "IfcBuilding";
                facility.ExternalFacilityIdentifier = ifcBuilding.GlobalId;

                facility.Description        = GetFacilityDescription(ifcBuilding);
                facility.ProjectDescription = GetFacilityProjectDescription(ifcProject);
                facility.SiteDescription    = GetFacilitySiteDescription(ifcSite);
                facility.Phase = (string.IsNullOrEmpty(ifcProject.Phase.ToString())) ? DEFAULT_STRING : ifcProject.Phase.ToString();

                facilities.AddRow(facility);


                //fill in the attribute information
                foreach (var ifcObject in ifcObjects)
                {
                    attributeBuilder.RowParameters["Name"]      = facility.Name;
                    attributeBuilder.RowParameters["CreatedBy"] = facility.CreatedBy;
                    attributeBuilder.RowParameters["CreatedOn"] = facility.CreatedOn;
                    attributeBuilder.RowParameters["ExtSystem"] = facility.ExternalSystem;
                    attributeBuilder.PopulateAttributesRows(ifcObject); //fill attribute sheet rows//pass data from this sheet info as Dictionary
                }
            }

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

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