コード例 #1
0
        /// <summary>
        /// Set the area measure to the building
        /// </summary>
        /// <param name="ifcBuilding">Building object</param>
        /// <param name="row">COBieFacilityRow object holding data</param>
        private void SetAreaMeasure(IfcBuilding ifcBuilding, COBieFacilityRow row)
        {
            IfcSIUnit ifcSIUnitArea = null;

            if (ValidateString(row.AreaUnits))
            {
                ifcSIUnitArea = GetSIUnit(row.AreaUnits);
            }
            string areaMeasure = string.Empty;

            if (ValidateString(row.AreaMeasurement))
            {
                areaMeasure = row.AreaMeasurement;
            }

            IfcQuantityArea IfcQuantityArea = Model.Instances.New <IfcQuantityArea>(qa =>
            {
                qa.Unit        = ifcSIUnitArea;
                qa.Name        = "AreaMeasure";
                qa.Description = "Created to maintain COBie information";
            });
            IfcElementQuantity ifcElementQuantity = Model.Instances.New <IfcElementQuantity>(eq =>
            {
                eq.Quantities.Add(IfcQuantityArea);
                eq.MethodOfMeasurement = areaMeasure;
                eq.Description         = "Created to maintain COBie information";
            });
            IfcRelDefinesByProperties ifcRelDefinesByProperties = Model.Instances.New <IfcRelDefinesByProperties>(rdbp =>
            {
                rdbp.RelatedObjects.Add(ifcBuilding);
                rdbp.RelatingPropertyDefinition = ifcElementQuantity;
                rdbp.Description = "Created to maintain COBie information";
            });
        }
コード例 #2
0
        /// <summary>
        /// Gets the Gross Floor Area, if the element base quantity GrossFloorArea is defined this has precedence
        /// If no property is defined the GFA is returned as the sume of the building storeys GFA
        /// </summary>
        /// <param name="building"></param>
        /// <returns></returns>
        public static IfcAreaMeasure?GetGrossFloorArea(this IfcBuilding building)
        {
            IfcQuantityArea qArea = building.GetQuantity <IfcQuantityArea>("BaseQuantities", "GrossFloorArea");

            if (qArea == null)
            {
                qArea = building.GetQuantity <IfcQuantityArea>("GrossFloorArea");               //just look for any area
            }
            if (qArea != null)
            {
                return(qArea.AreaValue);
            }
            IfcAreaMeasure area = 0;

            foreach (IfcBuildingStorey buildingStorey in building.GetBuildingStoreys())
            {
                IfcAreaMeasure?bsArea = buildingStorey.GetGrossFloorArea();
                if (bsArea.HasValue)
                {
                    area += bsArea;
                }
            }
            if (area != 0)
            {
                return(area);
            }
            return(null);
        }
コード例 #3
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);
            }
        }
コード例 #4
0
        /// <summary>
        /// Gets the area of the wall in elevation
        /// </summary>
        /// <param name="wall"></param>
        /// <returns></returns>
        public static IfcAreaMeasure?GetWallSideArea(this IfcWall wall)
        {
            IfcQuantityArea qArea = wall.GetQuantity <IfcQuantityArea>("BaseQuantities", "GrossSideArea");

            if (qArea == null)
            {
                qArea = wall.GetQuantity <IfcQuantityArea>("GrossSideArea");               //just look for any area
            }
            if (qArea != null)
            {
                return(qArea.AreaValue);
            }
            return(null);
        }
コード例 #5
0
        /// <summary>
        /// Returns the Gross Floor Area, if the element base quantity GrossFloorArea is defined
        /// </summary>
        /// <param name="buildingStorey"></param>
        /// <returns></returns>
        public static IfcAreaMeasure?GetGrossFloorArea(this IfcBuildingStorey buildingStorey)
        {
            IfcQuantityArea qArea = buildingStorey.GetQuantity <IfcQuantityArea>("BaseQuantities", "GrossFloorArea");

            if (qArea == null)
            {
                qArea = buildingStorey.GetQuantity <IfcQuantityArea>("GrossFloorArea");               //just look for any area
            }
            if (qArea != null)
            {
                return(qArea.AreaValue);
            }
            return(null);
        }
コード例 #6
0
        private static IfcNamedUnit resolveUnit(IIfcPhysicalQuantity quan)
        {
            IEntityCollection ifcModel = quan.Model.Instances;

            if (quan is IfcQuantityLength)
            {
                IfcQuantityLength ifcValue = (IfcQuantityLength)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.LENGTHUNIT)));
            }
            else if (quan is IfcQuantityArea)
            {
                IfcQuantityArea ifcValue = (IfcQuantityArea)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.AREAUNIT)));
            }
            else if (quan is IfcQuantityVolume)
            {
                IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.VOLUMEUNIT)));
            }
            else if (quan is IfcQuantityTime)
            {
                IfcQuantityTime ifcValue = (IfcQuantityTime)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.TIMEUNIT)));
            }
            else if (quan is IfcQuantityWeight)
            {
                IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.MASSUNIT)));
            }
            else if (quan is IfcQuantityCount)
            {
                IfcQuantityCount ifcValue = (IfcQuantityCount)quan;
                return(ifcValue.Unit);
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
        /// <summary>
        /// Returns the Gross Floor Area, if the element base quantity GrossFloorArea is defined
        /// </summary>
        /// <returns></returns>
        public static IfcAreaMeasure GetGrossFloorArea(this IfcSpace space)
        {
            IfcQuantityArea qArea = space.GetQuantity <IfcQuantityArea>("BaseQuantities", "GrossFloorArea");

            if (qArea == null)
            {
                qArea = space.GetQuantity <IfcQuantityArea>("GrossFloorArea");               //just look for any area
            }
            if (qArea != null)
            {
                return(qArea.AreaValue);
            }
            //try none schema defined properties

            return(null);
        }
コード例 #8
0
        /// <summary>
        /// Add Net Floor Area
        /// </summary>
        /// <param name="ifcSpace">IfcSpace Object</param>
        /// <param name="areaValue">Area value as string</param>
        private void AddNetArea(IfcSpace ifcSpace, string areaValue)
        {
            if (ValidateString(areaValue)) //ifcSpace.AddQuantity()
            {
                double?area = GetDoubleFromString(areaValue);
                if (area != null)
                {
                    IfcQuantityArea ifcQuantityArea = Model.Instances.New <IfcQuantityArea>(qa => { qa.Name = "NetFloorArea"; qa.Description = "Net Floor Area"; qa.AreaValue = new IfcAreaMeasure((double)area); });
                    string          appname         = "";
                    if (ifcSpace.OwnerHistory.OwningApplication != null)
                    {
                        appname = ifcSpace.OwnerHistory.OwningApplication.ApplicationFullName.ToString();
                    }

                    ifcSpace.AddQuantity("BaseQuantities", ifcQuantityArea, appname);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Returns the Gross Footprint Area, if the element base quantity GrossFloorArea is defined
        /// </summary>
        /// <returns></returns>
        public static IfcAreaMeasure GrossFootprintArea(this IfcSlab slab)
        {
            IfcQuantityArea qArea = slab.GetQuantity <IfcQuantityArea>("BaseQuantities", "GrossFootprintArea");

            if (qArea == null)
            {
                qArea = slab.GetQuantity <IfcQuantityArea>("GrossFootprintArea");               //just look for any area
            }
            if (qArea == null)
            {
                qArea = slab.GetQuantity <IfcQuantityArea>("CrossArea");               //just look for any area if revit has done it
            }
            if (qArea != null)
            {
                return(qArea.AreaValue);
            }
            //try none schema defined properties

            return(null);
        }
コード例 #10
0
        /// <summary>
        /// Returns the projected footprint are of the site, this value is derived and makes use of property sets not in the ifc schema
        /// </summary>
        /// <param name="site"></param>
        /// <returns></returns>
        public static IfcAreaMeasure?GetFootprintArea(this IfcSite site)
        {
            IfcQuantityArea qArea = site.GetQuantity <IfcQuantityArea>("BaseQuantities", "GrossArea");

            if (qArea == null)
            {
                qArea = site.GetQuantity <IfcQuantityArea>("GrossArea");              //just look for any area
            }
            if (qArea != null)
            {
                return(qArea.AreaValue);
            }
            //if revit try their value
            IfcAreaMeasure val = site.GetPropertySingleValue <IfcAreaMeasure>("PSet_Revit_Dimensions", "Projected Area");

            if (val != null)
            {
                return(val);
            }

            return(null);
        }
コード例 #11
0
 private static IfcUnit resolveUnit(IIfcPhysicalQuantity quan)
 {
     if (quan is IfcQuantityLength)
     {
         IfcQuantityLength ifcValue = (IfcQuantityLength)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityArea)
     {
         IfcQuantityArea ifcValue = (IfcQuantityArea)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityVolume)
     {
         IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityTime)
     {
         IfcQuantityTime ifcValue = (IfcQuantityTime)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityWeight)
     {
         IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityCount)
     {
         IfcQuantityCount ifcValue = (IfcQuantityCount)quan;
         return(ifcValue.Unit);
     }
     else
     {
         return(null);
     }
 }
コード例 #12
0
 private static IfcValue resolveValue(IIfcPhysicalQuantity quan)
 {
     if (quan is IfcQuantityLength)
     {
         IfcQuantityLength ifcValue = (IfcQuantityLength)quan;
         return(new IfcLengthMeasure(ifcValue.LengthValue.ToString()));
     }
     else if (quan is IfcQuantityArea)
     {
         IfcQuantityArea ifcValue = (IfcQuantityArea)quan;
         return(new IfcAreaMeasure(ifcValue.AreaValue.ToString()));
     }
     else if (quan is IfcQuantityVolume)
     {
         IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan;
         return(new IfcVolumeMeasure(ifcValue.VolumeValue.ToString()));
     }
     else if (quan is IfcQuantityTime)
     {
         IfcQuantityTime ifcValue = (IfcQuantityTime)quan;
         return(new IfcTimeMeasure(ifcValue.TimeValue.ToString()));
     }
     else if (quan is IfcQuantityWeight)
     {
         IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan;
         return(new IfcMassMeasure(ifcValue.WeightValue));
     }
     else if (quan is IfcQuantityCount)
     {
         IfcQuantityCount ifcValue = (IfcQuantityCount)quan;
         return(new IfcCountMeasure(ifcValue.CountValue.ToString()));
     }
     else
     {
         return(null);
     }
 }
コード例 #13
0
ファイル: IfcBuilding.cs プロジェクト: sxh2000251/Ifc.NET
        public void InitializeAdditionalProperties()
        {
            // default value
            this.IsLandmarked       = false;
            this.YearOfConstruction = "";
            this.NumberOfStoreys    = 0;
            this.OccupancyType      = "";

            Ifc4.IfcPropertySet ifcPropertySet = this.GetIfcPropertySetFromRelatingPropertyDefinition();

            IEnumerable <IfcProperty> ifcPropertyCollection = this.Document.IfcXmlDocument.Items.OfType <IfcProperty>().ToList();

            if (ifcPropertySet == null)
            {
                ifcPropertySet = new IfcPropertySet();
            }

            if (ifcPropertySet.HasProperties == null)
            {
                ifcPropertySet.HasProperties = new IfcPropertySetHasProperties();
            }

            m_IfcPropertySingleValueCollection = new List <IfcPropertySingleValue>();
            foreach (IfcProperty ifcPropertyTmp in ifcPropertySet.HasProperties.Items)
            {
                if (ifcPropertyTmp.IsRef)
                {
                    IfcProperty ifcProperty = ifcPropertyCollection.FirstOrDefault(item => item.Id == ifcPropertyTmp.Ref);
                    if (ifcProperty != null && ifcProperty is IfcPropertySingleValue)
                    {
                        m_IfcPropertySingleValueCollection.Add((IfcPropertySingleValue)ifcProperty);
                    }
                }
            }

            IfcPropertySingleValue ifcPropertySingleValue = null;

            ifcPropertySingleValue = m_IfcPropertySingleValueCollection.FirstOrDefault(item => item.Name.Equals("IsLandmarked", StringComparison.OrdinalIgnoreCase));
            if (ifcPropertySingleValue == null)
            {
                ifcPropertySingleValue = new Ifc4.IfcPropertySingleValue()
                {
                    Id           = this.Document.GetNextSid(),
                    Name         = "IsLandmarked",
                    NominalValue = new Ifc4.IfcPropertySingleValueNominalValue(),
                };

                ifcPropertySingleValue.NominalValue.Item = new Ifc4.IfcLogicalwrapper()
                {
                    Value = IsLandmarked ? Ifc4.IfcLogical.True : Ifc4.IfcLogical.False
                };

                m_IfcPropertySingleValueCollection.Add(ifcPropertySingleValue);
                this.Document.IfcXmlDocument.Items.Add(ifcPropertySingleValue);
                ifcPropertySet.HasProperties.Items.Add(new Ifc4.IfcPropertySingleValue()
                {
                    Ref = ifcPropertySingleValue.Id
                });
            }
            else
            {
                // read
                Ifc4.IfcLogicalwrapper ifcLogicalwrapper = ifcPropertySingleValue.NominalValue.Item as Ifc4.IfcLogicalwrapper;
                if (ifcLogicalwrapper != null)
                {
                    this.IsLandmarked = ifcLogicalwrapper.Value == IfcLogical.True ? true : false;
                }
            }

            ifcPropertySingleValue = m_IfcPropertySingleValueCollection.FirstOrDefault(item => item.Name.Equals("YearOfConstruction", StringComparison.OrdinalIgnoreCase));
            if (ifcPropertySingleValue == null)
            {
                ifcPropertySingleValue = new Ifc4.IfcPropertySingleValue()
                {
                    Id           = this.Document.GetNextSid(),
                    Name         = "YearOfConstruction",
                    NominalValue = new Ifc4.IfcPropertySingleValueNominalValue(),
                };

                ifcPropertySingleValue.NominalValue.Item = new Ifc4.IfcLabelwrapper()
                {
                    Value = this.YearOfConstruction
                };

                m_IfcPropertySingleValueCollection.Add(ifcPropertySingleValue);
                this.Document.IfcXmlDocument.Items.Add(ifcPropertySingleValue);
                ifcPropertySet.HasProperties.Items.Add(new Ifc4.IfcPropertySingleValue()
                {
                    Ref = ifcPropertySingleValue.Id
                });
            }
            else
            {
                // read
                Ifc4.IfcLabelwrapper ifcLabelwrapper = ifcPropertySingleValue.NominalValue.Item as Ifc4.IfcLabelwrapper;
                if (ifcLabelwrapper != null)
                {
                    this.YearOfConstruction = ifcLabelwrapper.Value;
                }
            }

            ifcPropertySingleValue = m_IfcPropertySingleValueCollection.FirstOrDefault(item => item.Name.Equals("NumberOfStoreys", StringComparison.OrdinalIgnoreCase));
            if (ifcPropertySingleValue == null)
            {
                ifcPropertySingleValue = new Ifc4.IfcPropertySingleValue()
                {
                    Id           = this.Document.GetNextSid(),
                    Name         = "NumberOfStoreys",
                    NominalValue = new Ifc4.IfcPropertySingleValueNominalValue(),
                };

                ifcPropertySingleValue.NominalValue.Item = new Ifc4.IfcIntegerwrapper()
                {
                    Value = this.NumberOfStoreys
                };


                m_IfcPropertySingleValueCollection.Add(ifcPropertySingleValue);
                this.Document.IfcXmlDocument.Items.Add(ifcPropertySingleValue);
                ifcPropertySet.HasProperties.Items.Add(new Ifc4.IfcPropertySingleValue()
                {
                    Ref = ifcPropertySingleValue.Id
                });
            }
            else
            {
                // read
                Ifc4.IfcIntegerwrapper ifcIntegerwrapper = ifcPropertySingleValue.NominalValue.Item as Ifc4.IfcIntegerwrapper;
                if (ifcIntegerwrapper != null)
                {
                    this.NumberOfStoreys = ifcIntegerwrapper.Value;
                }
            }

            ifcPropertySingleValue = m_IfcPropertySingleValueCollection.FirstOrDefault(item => item.Name.Equals("OccupancyType", StringComparison.OrdinalIgnoreCase));
            if (ifcPropertySingleValue == null)
            {
                ifcPropertySingleValue = new Ifc4.IfcPropertySingleValue()
                {
                    Id           = this.Document.GetNextSid(),
                    Name         = "OccupancyType",
                    NominalValue = new Ifc4.IfcPropertySingleValueNominalValue(),
                };

                ifcPropertySingleValue.NominalValue.Item = new Ifc4.IfcLabelwrapper()
                {
                    Value = this.OccupancyType
                };

                m_IfcPropertySingleValueCollection.Add(ifcPropertySingleValue);
                this.Document.IfcXmlDocument.Items.Add(ifcPropertySingleValue);
                ifcPropertySet.HasProperties.Items.Add(new Ifc4.IfcPropertySingleValue()
                {
                    Ref = ifcPropertySingleValue.Id
                });
            }
            else
            {
                // read
                Ifc4.IfcLabelwrapper ifcLabelwrapper = ifcPropertySingleValue.NominalValue.Item as Ifc4.IfcLabelwrapper;
                if (ifcLabelwrapper != null)
                {
                    this.OccupancyType = ifcLabelwrapper.Value;
                }
            }


            if (ifcPropertySet.Id == null)
            {
                ifcPropertySet.Id   = this.Document.GetNextSid();
                ifcPropertySet.Name = "Pset_BuildingCommon";
                this.Document.IfcXmlDocument.Items.Add(ifcPropertySet);

                Ifc4.IfcRelDefinesByProperties ifcRelDefinesByProperties = new Ifc4.IfcRelDefinesByProperties();
                ifcRelDefinesByProperties.Id = this.Document.GetNextSid();
                //ifcRelDefinesByProperties.RelatedObjects = new Ifc4.IfcBuilding() { Ref = this.Id };
                ifcRelDefinesByProperties.RelatedObjects                  = this.RefInstance();
                ifcRelDefinesByProperties.RelatingPropertyDefinition      = new Ifc4.IfcRelDefinesByPropertiesRelatingPropertyDefinition();
                ifcRelDefinesByProperties.RelatingPropertyDefinition.Item = new Ifc4.IfcPropertySet()
                {
                    Ref = ifcPropertySet.Id
                };
                this.Document.IfcXmlDocument.Items.Add(ifcRelDefinesByProperties);
            }

            // -----------------------------------------
            Ifc4.IfcElementQuantity ifcElementQuantity = this.GetIfcElementQuantityFromRelatingPropertyDefinition();
            if (ifcElementQuantity != null && ifcElementQuantity.IsRef)
            {
                ifcElementQuantity = this.Document.IfcXmlDocument.Items.OfType <IfcElementQuantity>().FirstOrDefault(item => item.Id == ifcElementQuantity.Ref);
            }

            IEnumerable <IfcQuantityArea> ifcQuantityAreaCollection = this.Document.IfcXmlDocument.Items.OfType <IfcQuantityArea>();

            if (ifcElementQuantity == null)
            {
                ifcElementQuantity = new IfcElementQuantity();
            }

            if (ifcElementQuantity.Quantities == null)
            {
                ifcElementQuantity.Quantities = new IfcElementQuantityQuantities();
            }


            m_IfcQuantityAreaCollection = new List <IfcQuantityArea>();
            foreach (IfcQuantityArea ifcQuantityAreaTmp in ifcElementQuantity.Quantities.Items)
            {
                if (ifcQuantityAreaTmp.IsRef)
                {
                    IfcQuantityArea existingIfcQuantityArea = ifcQuantityAreaCollection.FirstOrDefault(item => item.Id == ifcQuantityAreaTmp.Ref);
                    if (existingIfcQuantityArea != null)
                    {
                        m_IfcQuantityAreaCollection.Add(existingIfcQuantityArea);
                    }
                }
            }

            IfcQuantityArea ifcQuantityArea = null;

            ifcQuantityArea = m_IfcQuantityAreaCollection.FirstOrDefault(item => item.Name.Equals("GrossFloorArea", StringComparison.OrdinalIgnoreCase));
            if (ifcQuantityArea == null)
            {
                ifcQuantityArea = new IfcQuantityArea()
                {
                    Id        = this.Document.GetNextSid(),
                    Name      = "GrossFloorArea",
                    AreaValue = GrossFloorArea
                };

                m_IfcQuantityAreaCollection.Add(ifcQuantityArea);
                this.Document.IfcXmlDocument.Items.Add(ifcQuantityArea);
                ifcElementQuantity.Quantities.Items.Add(new Ifc4.IfcQuantityArea()
                {
                    Ref = ifcQuantityArea.Id
                });
            }
            else
            {
                // read
                this.GrossFloorArea = ifcQuantityArea.AreaValue;
            }

            ifcQuantityArea = m_IfcQuantityAreaCollection.FirstOrDefault(item => item.Name.Equals("NetFloorArea", StringComparison.OrdinalIgnoreCase));
            if (ifcQuantityArea == null)
            {
                ifcQuantityArea = new IfcQuantityArea()
                {
                    Id        = this.Document.GetNextSid(),
                    Name      = "NetFloorArea",
                    AreaValue = NetFloorArea
                };

                m_IfcQuantityAreaCollection.Add(ifcQuantityArea);
                this.Document.IfcXmlDocument.Items.Add(ifcQuantityArea);
                ifcElementQuantity.Quantities.Items.Add(new Ifc4.IfcQuantityArea()
                {
                    Ref = ifcQuantityArea.Id
                });
            }
            else
            {
                // read
                this.NetFloorArea = ifcQuantityArea.AreaValue;
            }

            if (ifcElementQuantity.Id == null)
            {
                ifcElementQuantity.Id   = this.Document.GetNextSid();
                ifcElementQuantity.Name = "Qto_BuildingBaseQuantities";
                this.Document.IfcXmlDocument.Items.Add(ifcElementQuantity);

                Ifc4.IfcRelDefinesByProperties ifcRelDefinesByProperties = new Ifc4.IfcRelDefinesByProperties();
                ifcRelDefinesByProperties.Id                         = this.Document.GetNextSid();
                ifcRelDefinesByProperties.RelatedObjects             = this.RefInstance();
                ifcRelDefinesByProperties.RelatingPropertyDefinition = new Ifc4.IfcRelDefinesByPropertiesRelatingPropertyDefinition();


                // old
                // ifcRelDefinesByProperties.RelatingPropertyDefinition.Item = new Ifc4.IfcElementQuantity() { Ref = ifcElementQuantity.Id };

                // new
                ifcRelDefinesByProperties.RelatingPropertyDefinition.Item = ((IfcPropertySetDefinition)(new Ifc4.IfcElementQuantity()
                {
                    Ref = ifcElementQuantity.Id
                }));

                this.Document.IfcXmlDocument.Items.Add(ifcRelDefinesByProperties);
            }
        }
コード例 #14
0
        public void InitializeAdditionalProperties()
        {
            Ifc4.IfcElementQuantity         ifcElementQuantity          = this.GetIfcElementQuantityFromRelatingPropertyDefinition();
            IEnumerable <IfcQuantityLength> ifcQuantityLengthCollection = this.Document.IfcXmlDocument.Items.OfType <IfcQuantityLength>().ToList();
            IEnumerable <IfcQuantityArea>   ifcQuantityAreaCollection   = this.Document.IfcXmlDocument.Items.OfType <IfcQuantityArea>().ToList();
            IEnumerable <IfcQuantityVolume> ifcQuantityVolumeCollection = this.Document.IfcXmlDocument.Items.OfType <IfcQuantityVolume>().ToList();

            if (ifcElementQuantity == null)
            {
                ifcElementQuantity = new IfcElementQuantity();
            }

            if (ifcElementQuantity.Quantities == null)
            {
                ifcElementQuantity.Quantities = new IfcElementQuantityQuantities();
            }
            // ---------------------------------------------------------------------------------------
            m_IfcQuantityLengthCollection = new List <IfcQuantityLength>();
            m_IfcQuantityAreaCollection   = new List <IfcQuantityArea>();
            m_IfcQuantityVolumeCollection = new List <IfcQuantityVolume>();

            foreach (IfcPhysicalQuantity ifcPhysicalQuantityTmp in ifcElementQuantity.Quantities.Items)
            {
                if (ifcPhysicalQuantityTmp.IsRef && ifcPhysicalQuantityTmp is IfcQuantityLength)
                {
                    IfcQuantityLength existingIfcQuantityLength = ifcQuantityLengthCollection.FirstOrDefault(item => item.Id == ifcPhysicalQuantityTmp.Ref);
                    if (existingIfcQuantityLength != null)
                    {
                        m_IfcQuantityLengthCollection.Add(existingIfcQuantityLength);
                    }
                }
                else if (ifcPhysicalQuantityTmp.IsRef && ifcPhysicalQuantityTmp is IfcQuantityArea)
                {
                    IfcQuantityArea existingIfcQuantityArea = ifcQuantityAreaCollection.FirstOrDefault(item => item.Id == ifcPhysicalQuantityTmp.Ref);
                    if (existingIfcQuantityArea != null)
                    {
                        m_IfcQuantityAreaCollection.Add(existingIfcQuantityArea);
                    }
                }
                else if (ifcPhysicalQuantityTmp.IsRef && ifcPhysicalQuantityTmp is IfcQuantityVolume)
                {
                    IfcQuantityVolume existingIfcQuantityVolume = ifcQuantityVolumeCollection.FirstOrDefault(item => item.Id == ifcPhysicalQuantityTmp.Ref);
                    if (existingIfcQuantityVolume != null)
                    {
                        m_IfcQuantityVolumeCollection.Add(existingIfcQuantityVolume);
                    }
                }
            }
            // ---------------------------------------------------------------------------------------
            string[] ifcQuantityLengthNames = new string[]
            {
                nameof(GrossHeight),
                nameof(NetHeight),
                nameof(GrossPerimeter)
            };
            foreach (var ifcQuantityLengthName in ifcQuantityLengthNames)
            {
                var ifcQuantityLengthPropertyInfo = this.GetType().GetProperty(ifcQuantityLengthName);
                if (ifcQuantityLengthPropertyInfo == null)
                {
                    continue;
                }

                var ifcQuantityLength = m_IfcQuantityLengthCollection.FirstOrDefault(item => item.Name.Equals(ifcQuantityLengthName, StringComparison.OrdinalIgnoreCase));
                if (ifcQuantityLength == null)
                {
                    ifcQuantityLength = new IfcQuantityLength()
                    {
                        Id          = this.Document.GetNextSid(),
                        Name        = ifcQuantityLengthName,
                        LengthValue = (double)ifcQuantityLengthPropertyInfo.GetValue(this, null)
                    };
                    m_IfcQuantityLengthCollection.Add(ifcQuantityLength);
                    this.Document.IfcXmlDocument.Items.Add(ifcQuantityLength);
                    ifcElementQuantity.Quantities.Items.Add(new Ifc4.IfcQuantityLength()
                    {
                        Ref = ifcQuantityLength.Id
                    });
                }
                else
                {
                    // read
                    ifcQuantityLengthPropertyInfo.SetValue(this, ifcQuantityLength.LengthValue, null);
                }
            }
            // ---------------------------------------------------------------------------------------
            string[] ifcQuantityAreaNames = new string[]
            {
                nameof(GrossFloorArea),
                nameof(NetFloorArea)
            };
            foreach (var ifcQuantityAreaName in ifcQuantityAreaNames)
            {
                var ifcQuantityAreaPropertyInfo = this.GetType().GetProperty(ifcQuantityAreaName);
                if (ifcQuantityAreaPropertyInfo == null)
                {
                    continue;
                }

                var ifcQuantityArea = m_IfcQuantityAreaCollection.FirstOrDefault(item => item.Name.Equals(ifcQuantityAreaName, StringComparison.OrdinalIgnoreCase));
                if (ifcQuantityArea == null)
                {
                    ifcQuantityArea = new IfcQuantityArea()
                    {
                        Id        = this.Document.GetNextSid(),
                        Name      = ifcQuantityAreaName,
                        AreaValue = (double)ifcQuantityAreaPropertyInfo.GetValue(this, null)
                    };
                    m_IfcQuantityAreaCollection.Add(ifcQuantityArea);
                    this.Document.IfcXmlDocument.Items.Add(ifcQuantityArea);
                    ifcElementQuantity.Quantities.Items.Add(new Ifc4.IfcQuantityArea()
                    {
                        Ref = ifcQuantityArea.Id
                    });
                }
                else
                {
                    // read
                    ifcQuantityAreaPropertyInfo.SetValue(this, ifcQuantityArea.AreaValue, null);
                }
            }
            // ---------------------------------------------------------------------------------------
            string[] ifcQuantityVolumeNames = new string[]
            {
                nameof(GrossVolume),
                nameof(NetVolume)
            };
            foreach (var ifcQuantityVolumeName in ifcQuantityVolumeNames)
            {
                var ifcQuantityVolumePropertyInfo = this.GetType().GetProperty(ifcQuantityVolumeName);
                if (ifcQuantityVolumePropertyInfo == null)
                {
                    continue;
                }

                var ifcQuantityVolume = m_IfcQuantityVolumeCollection.FirstOrDefault(item => item.Name.Equals(ifcQuantityVolumeName, StringComparison.OrdinalIgnoreCase));
                if (ifcQuantityVolume == null)
                {
                    ifcQuantityVolume = new IfcQuantityVolume()
                    {
                        Id          = this.Document.GetNextSid(),
                        Name        = ifcQuantityVolumeName,
                        VolumeValue = (double)ifcQuantityVolumePropertyInfo.GetValue(this, null)
                    };
                    m_IfcQuantityVolumeCollection.Add(ifcQuantityVolume);
                    this.Document.IfcXmlDocument.Items.Add(ifcQuantityVolume);
                    ifcElementQuantity.Quantities.Items.Add(new Ifc4.IfcQuantityVolume()
                    {
                        Ref = ifcQuantityVolume.Id
                    });
                }
                else
                {
                    // read
                    ifcQuantityVolumePropertyInfo.SetValue(this, ifcQuantityVolume.VolumeValue, null);
                }
            }
            // ---------------------------------------------------------------------------------------
            if (ifcElementQuantity.Id == null)
            {
                ifcElementQuantity.Id   = this.Document.GetNextSid();
                ifcElementQuantity.Name = "Qto_BuildingStoreyBaseQuantities";
                this.Document.IfcXmlDocument.Items.Add(ifcElementQuantity);

                Ifc4.IfcRelDefinesByProperties ifcRelDefinesByProperties = new Ifc4.IfcRelDefinesByProperties();
                ifcRelDefinesByProperties.Id                              = this.Document.GetNextSid();
                ifcRelDefinesByProperties.RelatedObjects                  = this.RefInstance();
                ifcRelDefinesByProperties.RelatingPropertyDefinition      = new Ifc4.IfcRelDefinesByPropertiesRelatingPropertyDefinition();
                ifcRelDefinesByProperties.RelatingPropertyDefinition.Item = new Ifc4.IfcElementQuantity()
                {
                    Ref = ifcElementQuantity.Id
                };
                this.Document.IfcXmlDocument.Items.Add(ifcRelDefinesByProperties);
            }
        }
コード例 #15
0
 public string GetAreaUnit(IfcQuantityArea areaUnit)
 {
     return(areaUnit.Unit != null?areaUnit.Unit.GetName() : ModelAreaUnit.ToString());
 }
コード例 #16
0
        private static void CreateElementQuantity(XbimModel model, IfcWallStandardCase wall, IfcOwnerHistory ifcOwnerHistory)
        {
            //Create a IfcElementQuantity
            //first we need a IfcPhysicalSimpleQuantity,first will use IfcQuantityArea
            IfcQuantityArea ifcQuantityArea = model.Instances.New <IfcQuantityArea>(qa =>
            {
                qa.Name        = "IfcQuantityArea:Area";
                qa.Description = "";
                qa.Unit        = model.Instances.New <IfcSIUnit>(siu =>
                {
                    siu.UnitType   = IfcUnitEnum.AREAUNIT;
                    siu.Prefix     = IfcSIPrefix.MILLI;
                    siu.Name       = IfcSIUnitName.SQUARE_METRE;
                    siu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de =>
                    {
                        de.LengthExponent                   = 1;
                        de.MassExponent                     = 0;
                        de.TimeExponent                     = 0;
                        de.ElectricCurrentExponent          = 0;
                        de.ThermodynamicTemperatureExponent = 0;
                        de.AmountOfSubstanceExponent        = 0;
                        de.LuminousIntensityExponent        = 0;
                    });
                });
                qa.AreaValue = 100.0;
            });
            //next quantity IfcQuantityCount using IfcContextDependentUnit
            IfcContextDependentUnit ifcContextDependentUnit = model.Instances.New <IfcContextDependentUnit>(cd =>
            {
                cd.Dimensions = model.Instances.New <IfcDimensionalExponents>(de =>
                {
                    de.LengthExponent                   = 1;
                    de.MassExponent                     = 0;
                    de.TimeExponent                     = 0;
                    de.ElectricCurrentExponent          = 0;
                    de.ThermodynamicTemperatureExponent = 0;
                    de.AmountOfSubstanceExponent        = 0;
                    de.LuminousIntensityExponent        = 0;
                });
                cd.UnitType = IfcUnitEnum.LENGTHUNIT;
                cd.Name     = "Elephants";
            });
            IfcQuantityCount ifcQuantityCount = model.Instances.New <IfcQuantityCount>(qc =>
            {
                qc.Name       = "IfcQuantityCount:Elephant";
                qc.CountValue = 12;
                qc.Unit       = ifcContextDependentUnit;
            });


            //next quantity IfcQuantityLength using IfcConversionBasedUnit
            IfcConversionBasedUnit ifcConversionBasedUnit = model.Instances.New <IfcConversionBasedUnit>(cbu =>
            {
                cbu.ConversionFactor = model.Instances.New <IfcMeasureWithUnit>(mu =>
                {
                    mu.ValueComponent = new IfcRatioMeasure(25.4);
                    mu.UnitComponent  = model.Instances.New <IfcSIUnit>(siu =>
                    {
                        siu.UnitType = IfcUnitEnum.LENGTHUNIT;
                        siu.Prefix   = IfcSIPrefix.MILLI;
                        siu.Name     = IfcSIUnitName.METRE;
                    });
                });
                cbu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de =>
                {
                    de.LengthExponent                   = 1;
                    de.MassExponent                     = 0;
                    de.TimeExponent                     = 0;
                    de.ElectricCurrentExponent          = 0;
                    de.ThermodynamicTemperatureExponent = 0;
                    de.AmountOfSubstanceExponent        = 0;
                    de.LuminousIntensityExponent        = 0;
                });
                cbu.UnitType = IfcUnitEnum.LENGTHUNIT;
                cbu.Name     = "Inch";
            });
            IfcQuantityLength ifcQuantityLength = model.Instances.New <IfcQuantityLength>(qa =>
            {
                qa.Name        = "IfcQuantityLength:Length";
                qa.Description = "";
                qa.Unit        = ifcConversionBasedUnit;
                qa.LengthValue = 24.0;
            });

            //lets create the IfcElementQuantity
            IfcElementQuantity ifcElementQuantity = model.Instances.New <IfcElementQuantity>(eq =>
            {
                eq.OwnerHistory = ifcOwnerHistory;
                eq.Name         = "Test:IfcElementQuantity";
                eq.Description  = "Measurement quantity";
                eq.Quantities.Add(ifcQuantityArea);
                eq.Quantities.Add(ifcQuantityCount);
                eq.Quantities.Add(ifcQuantityLength);
            });

            //need to create the relationship
            IfcRelDefinesByProperties ifcRelDefinesByProperties = model.Instances.New <IfcRelDefinesByProperties>(rdbp =>
            {
                rdbp.OwnerHistory = ifcOwnerHistory;
                rdbp.Name         = "Area Association";
                rdbp.Description  = "IfcElementQuantity associated to wall";
                rdbp.RelatedObjects.Add(wall);
                rdbp.RelatingPropertyDefinition = ifcElementQuantity;
            });
        }