Ejemplo n.º 1
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);
                if (!success && RevitBuiltInParameter != BuiltInParameter.INVALID)
                {
                    success = ParameterUtil.GetDoubleValueFromElementOrSymbol(element, RevitBuiltInParameter, out val);
                }
            }

            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);
        }
Ejemplo n.º 2
0
        /// <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>
        /// <returns>The property handle.</returns>
        IFCAnyHandle CreatePropertyFromCalculator(IFCFile file, ExporterIFC exporterIFC,
                                                  IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            IFCAnyHandle propHnd = null;

            if (PropertyCalculator != null && PropertyCalculator.Calculate(exporterIFC, extrusionCreationData, element, elementType))
            {
                PropertyType      propertyType = PropertyType;
                PropertyValueType valueType    = PropertyValueType;

                switch (propertyType)
                {
                case PropertyType.Label:
                {
                    if (PropertyCalculator.CalculatesMutipleValues)
                    {
                        propHnd = PropertyUtil.CreateLabelProperty(file, PropertyName, PropertyCalculator.GetStringValues(), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreateLabelPropertyFromCache(file, PropertyName, PropertyCalculator.GetStringValue(), valueType, false);
                    }
                    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.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:
                {
                    double scale = exporterIFC.LinearScale;
                    propHnd = PropertyUtil.CreateRealPropertyFromCache(file, scale, 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.PositiveRatio:
                {
                    propHnd = PropertyUtil.CreatePositiveRatioMeasureProperty(file, PropertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

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

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

                default:
                    throw new InvalidOperationException();
                }
            }

            return(propHnd);
        }