/// <summary>
        /// Add an entry to the quantity map.
        /// </summary>
        /// <param name="entry">The entry to add.</param>
        public QuantityEntry AddEntry(string name, string revitName, QuantityType quantityType, PropertyCalculator calculator)
        {
            QuantityEntry ifcQE = new QuantityEntry(revitName, name);

            ifcQE.QuantityType       = quantityType;
            ifcQE.PropertyCalculator = calculator;
            AddEntry(ifcQE);
            return(ifcQE);
        }
        /// <summary>
        /// Add an entry to the quantity map.
        /// </summary>
        /// <param name="entry">The entry to add.</param>
        public QuantityEntry AddEntry(string name, BuiltInParameter parameterName, QuantityType quantityType, PropertyCalculator calculator)
        {
            QuantityEntry ifcQE = new QuantityEntry(name, parameterName);

            ifcQE.QuantityType       = quantityType;
            ifcQE.PropertyCalculator = calculator;
            AddEntry(ifcQE);
            return(ifcQE);
        }
        /// <summary>
        /// Add an entry to the quantity map.
        /// </summary>
        /// <param name="name">The name of the quantity.</param>
        /// <param name="quantityType">The type of the quantity (e.g., area).</param>
        /// <param name="calculator">The PropertyCalculator that can generate the quantity value.</param>
        /// <param name="ignoreInternalValue">If true, don't use the internal Revit parameter of the same name.</param>
        /// <remarks>
        /// <paramref name="ignoreInternalValue"/> is intended to be used when the internal Revit
        /// parameter of the same name (depending on localization) has a different calculation than
        /// the IFC parameter.
        /// </remarks>
        public QuantityEntry AddEntry(string name, QuantityType quantityType,
                                      PropertyCalculator calculator, bool ignoreInternalValue = false)
        {
            QuantityEntry ifcQE = new QuantityEntry(name);

            ifcQE.QuantityType        = quantityType;
            ifcQE.PropertyCalculator  = calculator;
            ifcQE.IgnoreInternalValue = ignoreInternalValue;
            AddEntry(ifcQE);
            return(ifcQE);
        }
        /// <summary>
        /// Process to create element quantity.
        /// </summary>
        /// <param name="file">The IFC file.</param>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element of which this property is created for.</param>
        /// <param name="elementType">The element type of which this quantity is created for.</param>
        /// <returns>The created quantity handle.</returns>
        public IFCAnyHandle ProcessEntry(IFCFile file, ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData,
                                         Element element, ElementType elementType, QuantityEntry parentEntry)
        {
            bool useProperty = (!String.IsNullOrEmpty(RevitParameterName)) || (RevitBuiltInParameter != BuiltInParameter.INVALID);

            bool   success = false;
            object val     = 0;

            if (useProperty)
            {
                double dblVal = 0.0;

                if (parentEntry.QuantityType is QuantityType.Count)
                {
                    int?intValPar = null;
                    intValPar = (ParameterUtil.GetIntValueFromElementOrSymbol(element, RevitParameterName));
                    if (intValPar.HasValue)
                    {
                        success = true;
                        val     = intValPar.Value;
                    }
                }
                else
                {
                    success = (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, RevitParameterName, parentEntry.IgnoreInternalValue, out dblVal) != null);
                    if (!success && RevitBuiltInParameter != BuiltInParameter.INVALID)
                    {
                        success = (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, RevitBuiltInParameter, out dblVal) != null);
                    }
                    if (success)
                    {
                        val = dblVal;
                    }
                }

                if (success) // factor in the scale factor for all the parameters depending of the data type to get the correct value
                {
                    switch (parentEntry.QuantityType)
                    {
                    case QuantityType.PositiveLength:
                    case QuantityType.Length:
                        val = UnitUtil.ScaleLength((double)val);
                        break;

                    case QuantityType.Area:
                        val = UnitUtil.ScaleArea((double)val);
                        break;

                    case QuantityType.Volume:
                        val = UnitUtil.ScaleVolume((double)val);
                        break;

                    case QuantityType.Count:
                        break;

                    case QuantityType.Time:
                        break;

                    default:
                        break;
                    }
                }
            }

            if (PropertyCalculator != null && !success)
            {
                success = PropertyCalculator.Calculate(exporterIFC, extrusionCreationData, element, elementType, this);
                if (success && parentEntry.QuantityType == QuantityType.Count)
                {
                    val = PropertyCalculator.GetIntValue();
                }
                else
                {
                    val = PropertyCalculator.GetDoubleValue();
                }
            }

            IFCAnyHandle quantityHnd = null;

            if (success)
            {
                switch (parentEntry.QuantityType)
                {
                case QuantityType.PositiveLength:
                case QuantityType.Length:
                    quantityHnd = IFCInstanceExporter.CreateQuantityLength(file, parentEntry.PropertyName, parentEntry.MethodOfMeasurement, null, (double)val);
                    break;

                case QuantityType.Area:
                    quantityHnd = IFCInstanceExporter.CreateQuantityArea(file, parentEntry.PropertyName, parentEntry.MethodOfMeasurement, null, (double)val);
                    break;

                case QuantityType.Volume:
                    quantityHnd = IFCInstanceExporter.CreateQuantityVolume(file, parentEntry.PropertyName, parentEntry.MethodOfMeasurement, null, (double)val);
                    break;

                case QuantityType.Weight:
                    quantityHnd = IFCInstanceExporter.CreateQuantityWeight(file, parentEntry.PropertyName, parentEntry.MethodOfMeasurement, null, (double)val);
                    break;

                case QuantityType.Count:
                    quantityHnd = IFCInstanceExporter.CreateQuantityCount(file, parentEntry.PropertyName, parentEntry.MethodOfMeasurement, null, (int)val);
                    break;

                case QuantityType.Time:
                    quantityHnd = IFCInstanceExporter.CreateQuantityTime(file, parentEntry.PropertyName, parentEntry.MethodOfMeasurement, null, (double)val);
                    break;

                default:
                    throw new InvalidOperationException("Missing case!");
                }
            }

            return(quantityHnd);
        }
        /// <summary>
        /// Initializes COBIE space level quantities.
        /// </summary>
        /// <param name="cobieQuantities">List to store quantities.</param>
        private static void InitCOBIESpaceLevelQuantities(IList<QuantityDescription> cobieQuantities)
        {
            QuantityDescription ifcCOBIEQuantity = new QuantityDescription();
            ifcCOBIEQuantity.Name = "BaseQuantities";
            ifcCOBIEQuantity.EntityTypes.Add(IFCEntityType.IfcSpace);
            ifcCOBIEQuantity.DescriptionCalculator = SpaceLevelDescriptionCalculator.Instance;

            QuantityEntry ifcQE = new QuantityEntry("GrossFloorArea");
            ifcQE.MethodOfMeasurement = "area measured in geometry";
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.PropertyCalculator = SpaceLevelAreaCalculator.Instance;
            ifcCOBIEQuantity.AddEntry(ifcQE);

            cobieQuantities.Add(ifcCOBIEQuantity);
        }
        /// <summary>
        /// Initializes COBIE BM space quantities.
        /// </summary>
        /// <param name="cobieQuantities">List to store quantities.</param>
        private static void InitCOBIEPMSpaceQuantities(IList<QuantityDescription> cobieQuantities)
        {
            QuantityDescription ifcCOBIEQuantity = new QuantityDescription();
            ifcCOBIEQuantity.Name = "Space Quantities (Property Management)";
            ifcCOBIEQuantity.MethodOfMeasurement = "As defined by BOMA (see www.boma.org)";
            ifcCOBIEQuantity.EntityTypes.Add(IFCEntityType.IfcSpace);

            QuantityEntry ifcQE = new QuantityEntry("NetFloorArea_BOMA");
            ifcQE.MethodOfMeasurement = "area measured in geometry";
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.PropertyCalculator = SpaceAreaCalculator.Instance;
            ifcCOBIEQuantity.AddEntry(ifcQE);

            cobieQuantities.Add(ifcCOBIEQuantity);
        }
        /// <summary>
        /// Initializes Door base quantity
        /// </summary>
        /// <param name="baseQuantities"></param>
        private static void InitDoorBaseQuantities(IList<QuantityDescription> baseQuantities)
        {
            QuantityDescription ifcBaseQuantity = new QuantityDescription();
            ifcBaseQuantity.Name = "BaseQuantities";
            ifcBaseQuantity.EntityTypes.Add(IFCEntityType.IfcDoor);

            QuantityEntry ifcQE = new QuantityEntry("Height");
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.RevitBuiltInParameter = BuiltInParameter.DOOR_HEIGHT;
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("Width");
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.RevitBuiltInParameter = BuiltInParameter.DOOR_WIDTH;
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("Area");
            ifcQE.MethodOfMeasurement = "area measured in geometry";
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.PropertyCalculator = DoorAreaCalculator.Instance;
            ifcBaseQuantity.AddEntry(ifcQE);

            baseQuantities.Add(ifcBaseQuantity);
        }
        /// <summary>
        /// Initializes railing base quantities.
        /// </summary>
        /// <param name="baseQuantities">List to store quantities.</param>
        private static void InitRailingBaseQuantities(IList<QuantityDescription> baseQuantities)
        {
            QuantityDescription ifcRailingQuantity = new QuantityDescription();
            ifcRailingQuantity.Name = "BaseQuantities";
            ifcRailingQuantity.EntityTypes.Add(IFCEntityType.IfcRailing);

            QuantityEntry ifcQE = new QuantityEntry("Length");
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.RevitBuiltInParameter = BuiltInParameter.CURVE_ELEM_LENGTH;
            ifcRailingQuantity.AddEntry(ifcQE);

            baseQuantities.Add(ifcRailingQuantity);
        }
        /// <summary>
        /// Initializes Space base quantity
        /// </summary>
        /// <param name="baseQuantities"></param>
        private static void InitSpaceBaseQuantities(IList<QuantityDescription> baseQuantities)
        {
            QuantityDescription ifcBaseQuantity = new QuantityDescription();
            ifcBaseQuantity.Name = "BaseQuantities";
            ifcBaseQuantity.EntityTypes.Add(IFCEntityType.IfcSpace);

            QuantityEntry ifcQE = new QuantityEntry("NetFloorArea");
            ifcQE.MethodOfMeasurement = "area measured in geometry";
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.PropertyCalculator = SpaceAreaCalculator.Instance;
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("FinishCeilingHeight");
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.RevitParameterName = "IfcQtyFinishCeilingHeight";
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("NetCeilingArea");
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.RevitParameterName = "IfcQtyNetCeilingArea";
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("GrossCeilingArea");
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.RevitParameterName = "IfcQtyGrossCeilingArea";
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("NetWallArea");
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.RevitParameterName = "IfcQtyNetWallArea";
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("GrossWallArea");
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.RevitParameterName = "IfcQtyGrossWallArea";
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("Height");
            ifcQE.MethodOfMeasurement = "length measured in geometry";
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.PropertyCalculator = SpaceHeightCalculator.Instance;
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("NetPerimeter");
            ifcQE.MethodOfMeasurement = "length measured in geometry";
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.RevitParameterName = "IfcQtyNetPerimeter";
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("GrossPerimeter");
            ifcQE.MethodOfMeasurement = "length measured in geometry";
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.PropertyCalculator = SpacePerimeterCalculator.Instance;
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("GrossFloorArea");
            ifcQE.MethodOfMeasurement = "area measured in geometry";
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.PropertyCalculator = SpaceAreaCalculator.Instance;
            ifcBaseQuantity.AddEntry(ifcQE);

            ExportOptionsCache exportOptionsCache = ExporterCacheManager.ExportOptionsCache;
            if (!ExporterCacheManager.ExportOptionsCache.ExportAs2x3FMHandoverView)   // FMHandOver view exclude GrossVolumne, FinishFloorHeight
            {
                ifcQE = new QuantityEntry("GrossVolume");
                ifcQE.MethodOfMeasurement = "volume measured in geometry";
                ifcQE.QuantityType = QuantityType.Volume;
                ifcQE.PropertyCalculator = SpaceVolumeCalculator.Instance;
                ifcBaseQuantity.AddEntry(ifcQE);

                ifcQE = new QuantityEntry("FinishFloorHeight");
                ifcQE.QuantityType = QuantityType.PositiveLength;
                ifcQE.RevitParameterName = "IfcQtyFinishFloorHeight";
                ifcBaseQuantity.AddEntry(ifcQE);
            }

            baseQuantities.Add(ifcBaseQuantity);
        }
        /// <summary>
        /// Initializes Covering base quantity
        /// </summary>
        /// <param name="baseQuantities"></param>
        private static void InitCoveringBaseQuantities(IList<QuantityDescription> baseQuantities)
        {
            QuantityDescription ifcBaseQuantity = new QuantityDescription();
            ifcBaseQuantity.Name = "BaseQuantities";
            ifcBaseQuantity.EntityTypes.Add(IFCEntityType.IfcCovering);

            QuantityEntry ifcQE = new QuantityEntry("GrossArea");
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.RevitParameterName = "IfcQtyGrossArea";
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("NetArea");
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.RevitParameterName = "IfcQtyNetArea";
            ifcBaseQuantity.AddEntry(ifcQE);

            baseQuantities.Add(ifcBaseQuantity);
        }
        /// <summary>
        /// Initializes Building Storey base quantity
        /// </summary>
        /// <param name="baseQuantities"></param>
        private static void InitBuildingStoreyBaseQuantities(IList<QuantityDescription> baseQuantities)
        {
            QuantityDescription ifcBaseQuantity = new QuantityDescription();
            ifcBaseQuantity.Name = "BaseQuantities";
            ifcBaseQuantity.EntityTypes.Add(IFCEntityType.IfcBuildingStorey);

            QuantityEntry ifcQE = new QuantityEntry("NetHeight");
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.RevitParameterName = "IfcQtyNetHeight";
            ifcBaseQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("GrossHeight");
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.RevitParameterName = "IfcQtyGrossHeight";
            ifcBaseQuantity.AddEntry(ifcQE);

            ExportOptionsCache exportOptionsCache = ExporterCacheManager.ExportOptionsCache;
            if (!ExporterCacheManager.ExportOptionsCache.ExportAs2x3FMHandoverView)   // FMHandOver view exclude NetArea, GrossArea, NetVolume and GrossVolumne
            {
                ifcQE = new QuantityEntry("NetFloorArea");
                ifcQE.QuantityType = QuantityType.Area;
                ifcQE.PropertyCalculator = SpaceLevelAreaCalculator.Instance;
                ifcBaseQuantity.AddEntry(ifcQE);

                ifcQE = new QuantityEntry("GrossFloorArea");
                ifcQE.QuantityType = QuantityType.Area;
                ifcQE.PropertyCalculator = SpaceLevelAreaCalculator.Instance;
                ifcBaseQuantity.AddEntry(ifcQE);

                ifcQE = new QuantityEntry("GrossPerimeter");
                ifcQE.QuantityType = QuantityType.PositiveLength;
                ifcQE.RevitParameterName = "IfcQtyGrossPerimeter";
                ifcBaseQuantity.AddEntry(ifcQE);

                ifcQE = new QuantityEntry("NetVolume");
                ifcQE.QuantityType = QuantityType.Volume;
                ifcQE.RevitParameterName = "IfcQtyNetVolume";
                ifcBaseQuantity.AddEntry(ifcQE);

                ifcQE = new QuantityEntry("GrossVolume");
                ifcQE.QuantityType = QuantityType.Volume;
                ifcQE.RevitParameterName = "IfcQtyGrossVolume";
                ifcBaseQuantity.AddEntry(ifcQE);
            }

            baseQuantities.Add(ifcBaseQuantity);
        }
        /// <summary>
        /// Initializes ramp flight base quantities.
        /// </summary>
        /// <param name="baseQuantities">List to store quantities.</param>
        private static void InitRampFlightBaseQuantities(IList<QuantityDescription> baseQuantities)
        {
            QuantityDescription ifcBaseQuantity = new QuantityDescription();
            ifcBaseQuantity.Name = "BaseQuantities";
            ifcBaseQuantity.EntityTypes.Add(IFCEntityType.IfcRampFlight);

            QuantityEntry ifcQE = new QuantityEntry("Width");
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.RevitBuiltInParameter = BuiltInParameter.STAIRS_ATTR_TREAD_WIDTH;
            ifcBaseQuantity.AddEntry(ifcQE);

            baseQuantities.Add(ifcBaseQuantity);
        }
        /// <summary>
        /// Initializes slab base quantities.
        /// </summary>
        /// <param name="baseQuantities">List to store quantities.</param>
        private static void InitSlabBaseQuantities(IList<QuantityDescription> baseQuantities)
        {
            QuantityDescription ifcSlabQuantity = new QuantityDescription();
            ifcSlabQuantity.Name = "BaseQuantities";
            ifcSlabQuantity.EntityTypes.Add(IFCEntityType.IfcSlab);

            QuantityEntry ifcQE = new QuantityEntry("GrossArea");
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.PropertyCalculator = SlabGrossAreaCalculator.Instance;
            ifcSlabQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("GrossVolume");
            ifcQE.QuantityType = QuantityType.Volume;
            ifcQE.PropertyCalculator = SlabGrossVolumeCalculator.Instance;
            ifcSlabQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("Perimeter");
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.PropertyCalculator = SlabPerimeterCalculator.Instance;
            ifcSlabQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("Width");
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.PropertyCalculator = SlabWidthCalculator.Instance;
            ifcSlabQuantity.AddEntry(ifcQE);

            baseQuantities.Add(ifcSlabQuantity);
        }
Beispiel #14
0
 /// <summary>
 /// The entries stored in this property set description.
 /// </summary>
 public void AddEntry(QuantityEntry entry)
 {
     entry.UpdateEntry();
     m_Entries.Add(entry);
 }
        /// <summary>
        /// Initializes COBIE space quantities.
        /// </summary>
        /// <param name="cobieQuantities">List to store quantities.</param>
        private static void InitCOBIESpaceQuantities(IList<QuantityDescription> cobieQuantities)
        {
            QuantityDescription ifcCOBIEQuantity = new QuantityDescription();
            ifcCOBIEQuantity.Name = "BaseQuantities";
            ifcCOBIEQuantity.EntityTypes.Add(IFCEntityType.IfcSpace);

            QuantityEntry ifcQE = new QuantityEntry("Height");
            ifcQE.MethodOfMeasurement = "length measured in geometry";
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.PropertyCalculator = SpaceHeightCalculator.Instance;
            ifcCOBIEQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("GrossPerimeter");
            ifcQE.MethodOfMeasurement = "length measured in geometry";
            ifcQE.QuantityType = QuantityType.PositiveLength;
            ifcQE.PropertyCalculator = SpacePerimeterCalculator.Instance;
            ifcCOBIEQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("GrossFloorArea");
            ifcQE.MethodOfMeasurement = "area measured in geometry";
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.PropertyCalculator = SpaceAreaCalculator.Instance;
            ifcCOBIEQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("NetFloorArea");
            ifcQE.MethodOfMeasurement = "area measured in geometry";
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.PropertyCalculator = SpaceAreaCalculator.Instance;
            ifcCOBIEQuantity.AddEntry(ifcQE);

            ifcQE = new QuantityEntry("GrossVolume");
            ifcQE.MethodOfMeasurement = "volume measured in geometry";
            ifcQE.QuantityType = QuantityType.Volume;
            ifcQE.PropertyCalculator = SpaceVolumeCalculator.Instance;
            ifcCOBIEQuantity.AddEntry(ifcQE);

            cobieQuantities.Add(ifcCOBIEQuantity);
        }
 /// <summary>
 /// The entries stored in this property set description.
 /// </summary>
 public void AddEntry(QuantityEntry entry)
 {
     entry.UpdateEntry();
     m_Entries.Add(entry);
 }
        // Quantities

        /// <summary>
        /// Initializes ceiling base quantities.
        /// </summary>
        /// <param name="baseQuantities">List to store quantities.</param>
        private static void InitCeilingBaseQuantities(IList<QuantityDescription> baseQuantities)
        {
            QuantityDescription ifcCeilingQuantity = new QuantityDescription();
            ifcCeilingQuantity.Name = "BaseQuantities";
            ifcCeilingQuantity.EntityTypes.Add(IFCEntityType.IfcCovering);

            QuantityEntry ifcQE = new QuantityEntry("GrossCeilingArea");
            ifcQE.QuantityType = QuantityType.Area;
            ifcQE.RevitBuiltInParameter = BuiltInParameter.HOST_AREA_COMPUTED;
            ifcCeilingQuantity.AddEntry(ifcQE);

            baseQuantities.Add(ifcCeilingQuantity);
        }