Пример #1
0
        /// <summary>
        /// Calculates number of risers for a stair.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="extrusionCreationData">
        /// The IFCExtrusionCreationData.
        /// </param>
        /// <param name="element">
        /// The element to calculate the value.
        /// </param>
        /// <param name="elementType">
        /// The element type.
        /// </param>
        /// <returns>
        /// True if the operation succeed, false otherwise.
        /// </returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            bool valid = true;

            if (StairsExporter.IsLegacyStairs(element))
            {
                double riserHeight, treadLength, treadLengthAtInnerSide, nosingLength, waistThickness = 0;
                int    numberOfTreads = 0;

                ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element,
                                                           out m_NumberOfRisers, out numberOfTreads,
                                                           out riserHeight, out treadLength, out treadLengthAtInnerSide,
                                                           out nosingLength, out waistThickness);
            }
            else if (element is Stairs)
            {
                Stairs stairs = element as Stairs;
                m_NumberOfRisers = stairs.ActualRisersNumber;
            }
            else if (element is StairsRun)
            {
                StairsRun     stairsRun     = element as StairsRun;
                StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType;
                m_NumberOfRisers = stairsRun.ActualRisersNumber;
            }
            else
            {
                valid = false;
            }

            // Get override from parameter
            ParameterUtil.GetIntValueFromElementOrSymbol(element, "NumberOfRiser", out m_NumberOfRisers);

            return(valid);
        }
Пример #2
0
        /// <summary>
        /// Calculates external value for an element.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element to calculate the value.</param>
        /// <param name="elementType">The element type.</param>
        /// <returns>True if the operation succeed, false otherwise.</returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            int isExternalInt = 0;

            ParameterUtil.GetIntValueFromElementOrSymbol(element, "IsExternal", out isExternalInt);
            if (isExternalInt != 0)
            {
                m_IsExternal = true;
            }

            m_IsExternal = CategoryUtil.IsElementExternal(element);
            return(true);
        }
Пример #3
0
        /// <summary>
        /// Calculates concealed value for a space.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element to calculate the value.</param>
        /// <param name="elementType">The element type.</param>
        /// <returns>True if the operation succeed, false otherwise.</returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType, EntryMap entryMap)
        {
            int?concealedFlooringOffset = ParameterUtil.GetIntValueFromElementOrSymbol(element, entryMap.RevitParameterName);

            if (!concealedFlooringOffset.HasValue)
            {
                concealedFlooringOffset = ParameterUtil.GetIntValueFromElementOrSymbol(element, entryMap.CompatibleRevitParameterName);
            }
            if (!concealedFlooringOffset.HasValue)
            {
                return(false);
            }

            Concealed = concealedFlooringOffset.GetValueOrDefault(0) != 0;
            return(true);
        }
Пример #4
0
        /// <summary>
        /// Calculates load bearing value for a wall.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="calcValues">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element to calculate the value.</param>
        /// <param name="elementType">The element type.</param>
        /// <returns>True if the operation succeeded, false otherwise.</returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType, EntryMap entryMap)
        {
            Wall wall = element as Wall;

            if (wall != null)
            {
                m_LoadBearing = wall.StructuralUsage == StructuralWallUsage.Bearing;
                return(true);
            }

            // This may be set for Column, Beam, Brace
            ElementId catId = CategoryUtil.GetSafeCategoryId(element);

            if (catId == new ElementId(BuiltInCategory.OST_StructuralColumns) ||
                catId == new ElementId(BuiltInCategory.OST_StructuralFraming) ||
                catId == new ElementId(BuiltInCategory.OST_StructuralFramingSystem) ||
                catId == new ElementId(BuiltInCategory.OST_StructuralTruss))
            {
                m_LoadBearing = true;
                return(true);
            }

            // This is for Floor/Slab
            Parameter parameter = element.get_Parameter(BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL);

            if (parameter != null && parameter.HasValue && parameter.StorageType == StorageType.Integer)
            {
                m_LoadBearing = (parameter.AsInteger() != 0) ? true : false;
                return(true);
            }

            // If other entities, look for the parameter value for Load Bearing
            int?intLoadBearing = ParameterUtil.GetIntValueFromElementOrSymbol(element, entryMap.RevitParameterName);

            if (!intLoadBearing.HasValue)
            {
                ParameterUtil.GetIntValueFromElementOrSymbol(element, entryMap.CompatibleRevitParameterName);
            }

            if (!intLoadBearing.HasValue)
            {
                return(false);
            }

            m_LoadBearing = (intLoadBearing.Value != 0);
            return(true);
        }
Пример #5
0
        /// <summary>
        /// Calculates concealed value for a space.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element to calculate the value.</param>
        /// <param name="elementType">The element type.</param>
        /// <returns>True if the operation succeed, false otherwise.</returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            int?concealedFlooring = ParameterUtil.GetIntValueFromElementOrSymbol(element, "ConcealedFlooring");
            int?concealedCovering = ParameterUtil.GetIntValueFromElementOrSymbol(element, "ConcealedCovering");

            if (concealedFlooring.HasValue || concealedCovering.HasValue)
            {
                Concealed =
                    concealedFlooring.GetValueOrDefault(0) != 0 || concealedCovering.GetValueOrDefault(0) != 0;
                return(true);
            }

            int?concealed = ParameterUtil.GetIntValueFromElementOrSymbol(element, "Concealed");

            Concealed = concealed.GetValueOrDefault(0) != 0;

            return(true);
        }
Пример #6
0
        /// <summary>
        /// Calculates concealed value for a space.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element to calculate the value.</param>
        /// <param name="elementType">The element type.</param>
        /// <returns>True if the operation succeed, false otherwise.</returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            int concealedFlooring = 0, concealedCovering = 0;

            if ((ParameterUtil.GetIntValueFromElementOrSymbol(element, "ConcealedFlooring", out concealedFlooring) != null) ||
                (ParameterUtil.GetIntValueFromElementOrSymbol(element, "ConcealedCovering", out concealedCovering) != null))
            {
                m_Concealed = concealedFlooring != 0 || concealedCovering != 0;
                return(true);
            }

            int concealed = 0;

            ParameterUtil.GetIntValueFromElementOrSymbol(element, "Concealed", out concealed);
            m_Concealed = concealed != 0;

            return(true);
        }
        /// <summary>
        /// Calculates load bearing value for a wall.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="calcValues">
        /// The IFCExtrusionCreationData.
        /// </param>
        /// <param name="element">
        /// The element to calculate the value.
        /// </param>
        /// <param name="elementType">
        /// The element type.
        /// </param>
        /// <returns>
        /// True if the operation succeed, false otherwise.
        /// </returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            Wall wall = element as Wall;

            if (wall != null)
            {
                m_LoadBearing = wall.StructuralUsage == StructuralWallUsage.Bearing;
                return(true);
            }

            // This may be set for Column
            if (CategoryUtil.GetSafeCategoryId(element) == new ElementId(BuiltInCategory.OST_StructuralColumns))
            {
                m_LoadBearing = true;
                return(true);
            }

            // This is for Floor/Slab
            Parameter parameter = element.get_Parameter(BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL);

            if (parameter != null && parameter.HasValue && parameter.StorageType == StorageType.Integer)
            {
                m_LoadBearing = (parameter.AsInteger() != 0) ? true : false;
                return(true);
            }

            // If other entities, look for the parameter value for Load Bearing
            int intLoadBearing = 0;

            if (ParameterUtil.GetIntValueFromElementOrSymbol(element, "IfcLoadBearing", out intLoadBearing) == null)
            {
                if (ParameterUtil.GetIntValueFromElementOrSymbol(element, "LoadBearing", out intLoadBearing) == null)
                {
                    return(false);
                }
            }

            m_LoadBearing = (intLoadBearing != 0);
            return(true);
        }
Пример #8
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);
        }