示例#1
0
        /// <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>
        /// Create the PropertySetEntry for "LoadBearing", which is used by many property sets.
        /// </summary>
        /// <param name="calc">The appropriate calculator for the element type associated with this entry.</param>
        /// <returns>The correct PropertySetEntry.</returns>
        public static PropertySetEntry CreateLoadBearingEntry(PropertyCalculator calc)
        {
            PropertySetEntry ifcPSE = PropertySetEntry.CreateBoolean("LoadBearing");

            ifcPSE.AddLocalizedParameterName(LanguageType.Chinese_Simplified, "是否承重");
            ifcPSE.AddLocalizedParameterName(LanguageType.French, "Porteur");
            ifcPSE.AddLocalizedParameterName(LanguageType.German, "TragendesBauteil");
            ifcPSE.AddLocalizedParameterName(LanguageType.Japanese, "耐力部材");
            ifcPSE.PropertyCalculator = calc;
            return(ifcPSE);
        }
示例#3
0
        /// <summary>
        /// Create the PropertySetEntry for "LoadBearing", which is used by many property sets.
        /// </summary>
        /// <param name="calc">The appropriate calculator for the element type associated with this entry.</param>
        /// <returns>The correct PropertySetEntry.</returns>
        public static PropertySetEntry CreateLoadBearingEntry(PropertyCalculator calc)
        {
            string name = "LoadBearing";
            PropertySetEntryMap ifcPSE = new PropertySetEntryMap(name);

            ifcPSE.AddLocalizedParameterName(LanguageType.Chinese_Simplified, "是否承重");
            ifcPSE.AddLocalizedParameterName(LanguageType.French, "Porteur");
            ifcPSE.AddLocalizedParameterName(LanguageType.German, "TragendesBauteil");
            ifcPSE.AddLocalizedParameterName(LanguageType.Japanese, "耐力部材");
            ifcPSE.PropertyCalculator = calc;
            return(new PropertySetEntry(PropertyType.Boolean, name, ifcPSE));
        }
示例#4
0
        public static PropertySetEntry CreateRollEntry(PropertyCalculator propertyCalculator)
        {
            string name = "Roll";
            PropertySetEntryMap ifcPSE = new PropertySetEntryMap(name)
            {
                PropertyCalculator = propertyCalculator
            };

            ifcPSE.AddLocalizedParameterName(LanguageType.German, "Kippwinkel");
            ifcPSE.AddLocalizedParameterName(LanguageType.French, "RotationAutourAxeLongitudinal");
            ifcPSE.AddLocalizedParameterName(LanguageType.Japanese, "回転");
            ifcPSE.AddLocalizedParameterName(LanguageType.Chinese_Simplified, "转角");
            return(new PropertySetEntry(PropertyType.PlaneAngle, name, ifcPSE));
        }
示例#5
0
        public static PropertySetEntry CreateSlopeEntry(PropertyCalculator propertyCalculator)
        {
            string name = "Slope";
            PropertySetEntryMap ifcPSE = new PropertySetEntryMap(name)
            {
                PropertyCalculator = propertyCalculator
            };

            ifcPSE.AddLocalizedParameterName(LanguageType.German, "Neigungswinkel");
            ifcPSE.AddLocalizedParameterName(LanguageType.French, "Inclinaison");
            ifcPSE.AddLocalizedParameterName(LanguageType.Japanese, "傾斜");
            ifcPSE.AddLocalizedParameterName(LanguageType.Chinese_Simplified, "坡度");
            return(new PropertySetEntry(PropertyType.PlaneAngle, name, ifcPSE));
        }
示例#6
0
        public static PropertySetEntry CreateSpanEntry(PropertyCalculator propertyCalculator)
        {
            string name = "Span";
            PropertySetEntryMap ifcPSE = new PropertySetEntryMap(name)
            {
                PropertyCalculator = propertyCalculator
            };

            ifcPSE.AddLocalizedParameterName(LanguageType.German, "Spannweite");
            ifcPSE.AddLocalizedParameterName(LanguageType.French, "PorteeLibre");
            ifcPSE.AddLocalizedParameterName(LanguageType.Japanese, "全長");
            ifcPSE.AddLocalizedParameterName(LanguageType.Chinese_Simplified, "跨度");
            return(new PropertySetEntry(PropertyType.PositiveLength, name, ifcPSE));
        }
 public PropertySetEntryMap(PropertyCalculator calculator)
     : base(calculator)
 {
 }
        /// <summary>
        /// Creates a property from the calculator.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="exporterIFC">The ExporterIFC.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element.</param>
        /// <param name="elementType">The element type.</param>
        /// <param name="handle">The handle for which we calculate the property.</param>
        /// <returns>The property handle.</returns>
        IFCAnyHandle CreatePropertyFromCalculator(IFCFile file, ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element,
                                                  ElementType elementType, IFCAnyHandle handle, PropertyType propertyType, PropertyValueType valueType, Type propertyEnumerationType, string propertyName)
        {
            IFCAnyHandle propHnd = null;

            if (PropertyCalculator == null)
            {
                return(propHnd);
            }

            if (PropertyCalculator.GetParameterFromSubelementCache(element, handle) ||
                PropertyCalculator.Calculate(exporterIFC, extrusionCreationData, element, elementType))
            {
                switch (propertyType)
                {
                case PropertyType.Label:
                {
                    if (PropertyCalculator.CalculatesMutipleValues)
                    {
                        propHnd = PropertyUtil.CreateLabelProperty(file, propertyName, PropertyCalculator.GetStringValues(), valueType, propertyEnumerationType);
                    }
                    else
                    {
                        bool cacheLabel = PropertyCalculator.CacheStringValues;
                        propHnd = PropertyUtil.CreateLabelPropertyFromCache(file, null, propertyName, PropertyCalculator.GetStringValue(), valueType, cacheLabel, propertyEnumerationType);
                    }
                    break;
                }

                case PropertyType.Text:
                {
                    propHnd = PropertyUtil.CreateTextPropertyFromCache(file, propertyName, PropertyCalculator.GetStringValue(), valueType);
                    break;
                }

                case PropertyType.Identifier:
                {
                    propHnd = PropertyUtil.CreateIdentifierPropertyFromCache(file, propertyName, PropertyCalculator.GetStringValue(), valueType);
                    break;
                }

                case PropertyType.Boolean:
                {
                    propHnd = PropertyUtil.CreateBooleanPropertyFromCache(file, propertyName, PropertyCalculator.GetBooleanValue(), valueType);
                    break;
                }

                case PropertyType.Logical:
                {
                    propHnd = PropertyUtil.CreateLogicalPropertyFromCache(file, propertyName, PropertyCalculator.GetLogicalValue(), valueType);
                    break;
                }

                case PropertyType.Integer:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreateIntegerPropertyFromCache(file, propertyName, PropertyCalculator.GetIntValue(propertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreateIntegerPropertyFromCache(file, propertyName, PropertyCalculator.GetIntValue(), valueType);
                    }
                    break;
                }

                case PropertyType.Real:
                {
                    propHnd = PropertyUtil.CreateRealPropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Length:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreateLengthMeasurePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(propertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreateLengthMeasurePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    }
                    break;
                }

                case PropertyType.PositiveLength:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreatePositiveLengthMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(propertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreatePositiveLengthMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    }
                    break;
                }

                case PropertyType.NormalisedRatio:
                {
                    propHnd = PropertyUtil.CreateNormalisedRatioMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.PositiveRatio:
                {
                    propHnd = PropertyUtil.CreatePositiveRatioMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Ratio:
                {
                    propHnd = PropertyUtil.CreateRatioMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.PlaneAngle:
                {
                    propHnd = PropertyUtil.CreatePlaneAngleMeasurePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.PositivePlaneAngle:
                {
                    propHnd = PositivePlaneAnglePropertyUtil.CreatePositivePlaneAngleMeasurePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Area:
                {
                    propHnd = PropertyUtil.CreateAreaMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Count:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreateCountMeasureProperty(file, propertyName, PropertyCalculator.GetIntValue(propertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreateCountMeasureProperty(file, propertyName, PropertyCalculator.GetIntValue(), valueType);
                    }
                    break;
                }

                case PropertyType.Frequency:
                {
                    propHnd = FrequencyPropertyUtil.CreateFrequencyProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Power:
                {
                    propHnd = PropertyUtil.CreatePowerPropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.ThermodynamicTemperature:
                {
                    propHnd = PropertyUtil.CreateThermodynamicTemperaturePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.ThermalTransmittance:
                {
                    propHnd = PropertyUtil.CreateThermalTransmittancePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.VolumetricFlowRate:
                {
                    propHnd = PropertyUtil.CreateVolumetricFlowRateMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.LinearVelocity:
                {
                    propHnd = PropertyUtil.CreateLinearVelocityMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                default:
                    throw new InvalidOperationException();
                }
            }

            return(propHnd);
        }
示例#9
0
 public EntryMap(PropertyCalculator calculator)
 {
     PropertyCalculator = calculator;
 }
示例#10
0
        /// <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);
        }
示例#11
0
 public QuantityEntry(string propertyName, PropertyCalculator calculator)
     : base(propertyName, new QuantityEntryMap(propertyName) { PropertyCalculator = calculator })
 {
 }
示例#12
0
        /// <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);
        }
示例#13
0
        /// <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);
        }
示例#14
0
 /// <summary>
 /// Create the PropertySetEntry for "LoadBearing", which is used by many property sets.
 /// </summary>
 /// <param name="calc">The appropriate calculator for the element type associated with this entry.</param>
 /// <returns>The correct PropertySetEntry.</returns>
 public static PropertySetEntry CreateLoadBearingEntry(PropertyCalculator calc)
 {
     PropertySetEntry ifcPSE = PropertySetEntry.CreateBoolean("LoadBearing");
     ifcPSE.AddLocalizedParameterName(LanguageType.Chinese_Simplified, "是否承重");
     ifcPSE.AddLocalizedParameterName(LanguageType.French, "Porteur");
     ifcPSE.AddLocalizedParameterName(LanguageType.German, "TragendesBauteil");
     ifcPSE.AddLocalizedParameterName(LanguageType.Japanese, "耐力部材");
     ifcPSE.PropertyCalculator = calc;
     return ifcPSE;
 }
示例#15
0
 public PropertySetEntry(PropertyType propertyType, string propertyName, PropertyCalculator propertyCalculator)
     : base(propertyName, new PropertySetEntryMap(propertyName) { PropertyCalculator = propertyCalculator })
 {
     m_PropertyType = propertyType;
 }
示例#16
0
 public PropertySetEntry(PropertyType propertyType, string propertyName, BuiltInParameter builtInParameter, PropertyCalculator propertyCalculator)
     : base(propertyName, new PropertySetEntryMap(propertyName) { RevitBuiltInParameter = builtInParameter, PropertyCalculator = propertyCalculator })
 {
     m_PropertyType = propertyType;
 }
示例#17
0
 public QuantityEntryMap(PropertyCalculator calculator)
     : base(calculator)
 {
 }
示例#18
0
        /// <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>
        /// Then created quantity handle.
        /// </returns>
        public IFCAnyHandle ProcessEntry(IFCFile file, ExporterIFC exporterIFC,
                                         IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            bool useProperty = (!String.IsNullOrEmpty(RevitParameterName)) || (RevitBuiltInParameter != BuiltInParameter.INVALID);

            bool   success = false;
            double val     = 0;

            if (useProperty)
            {
                success = (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, RevitParameterName, out val) != null);
                if (!success && RevitBuiltInParameter != BuiltInParameter.INVALID)
                {
                    success = (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, RevitBuiltInParameter, out val) != null);
                }

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

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

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

                    default:
                        break;
                    }
                }
            }

            if (PropertyCalculator != null && !success)
            {
                success = PropertyCalculator.Calculate(exporterIFC, extrusionCreationData, element, elementType);
                if (success)
                {
                    val = PropertyCalculator.GetDoubleValue();
                }
            }

            IFCAnyHandle quantityHnd = null;

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

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

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

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

            return(quantityHnd);
        }
示例#19
0
 public EntryMap(PropertyCalculator calculator)
 {
     this.m_PropertyCalculator = calculator;
 }