/// <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 (m_CurrentElement != element)
            {
                double scale = exporterIFC.LinearScale;

                m_CurrentElement = element;
                if (StairsExporter.IsLegacyStairs(element))
                {
                    ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element,
                                                               out m_NumberOfRisers, out m_NumberOfTreads,
                                                               out m_RiserHeight, out m_TreadLength, out m_TreadLengthAtInnerSide,
                                                               out m_NosingLength, out m_WaistThickness);
                    m_TreadLengthAtOffset = m_TreadLength;
                    m_WalkingLineOffset   = m_WaistThickness / 2.0;
                }
                else if (element is Stairs)
                {
                    Stairs stairs = element as Stairs;
                    m_NumberOfRisers = stairs.ActualRisersNumber;
                    m_NumberOfTreads = stairs.ActualTreadsNumber;
                    m_RiserHeight    = stairs.ActualRiserHeight * scale;
                    m_TreadLength    = stairs.ActualTreadDepth * scale;
                }
                else if (element is StairsRun)
                {
                    StairsRun     stairsRun     = element as StairsRun;
                    StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType;
                    Stairs        stairs        = stairsRun.GetStairs();
                    StairsType    stairsType    = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType;

                    m_NumberOfRisers      = stairs.ActualRisersNumber;
                    m_NumberOfTreads      = stairs.ActualTreadsNumber;
                    m_RiserHeight         = stairs.ActualRiserHeight * scale;
                    m_TreadLength         = stairs.ActualTreadDepth * scale;
                    m_TreadLengthAtOffset = m_TreadLength;
                    m_NosingLength        = stairsRunType.NosingLength * scale;
                    m_WaistThickness      = stairsRun.ActualRunWidth * scale;
                    m_WalkingLineOffset   = m_WaistThickness / 2.0;

                    double treadLengthAtInnerSide;
                    if (ParameterUtil.GetDoubleValueFromElement(stairsType,
                                                                BuiltInParameter.STAIRSTYPE_MINIMUM_TREAD_WIDTH_INSIDE_BOUNDARY, out treadLengthAtInnerSide) != null)
                    {
                        m_TreadLengthAtInnerSide = treadLengthAtInnerSide * scale;
                    }
                    else
                    {
                        m_TreadLengthAtInnerSide = 0.0;
                    }
                }
                else
                {
                    valid = false;
                }
            }
            return(valid);
        }
        /// <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, EntryMap entryMap)
        {
            bool valid = true;

            if (StairsExporter.IsLegacyStairs(element))
            {
                double riserHeight, treadLength, nosingLength, waistThickness = 0;
                int    numberOfRisers, numberOfTreads = 0;
                ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element,
                                                           out numberOfRisers, out numberOfTreads,
                                                           out riserHeight, out treadLength, out m_TreadLengthAtInnerSide,
                                                           out nosingLength, out waistThickness);
            }
            else if (element is Stairs || element is StairsRun)
            {
                Stairs stairs;
                if (element is StairsRun)
                {
                    StairsRun stairsRun = element as StairsRun;
                    stairs = stairsRun.GetStairs();
                }
                else
                {
                    stairs = element as Stairs;
                }

                StairsType stairsType = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType;

                double treadLengthAtInnerSide;
                if (ParameterUtil.GetDoubleValueFromElement(stairsType,
                                                            BuiltInParameter.STAIRSTYPE_MINIMUM_TREAD_WIDTH_INSIDE_BOUNDARY, out treadLengthAtInnerSide) != null)
                {
                    m_TreadLengthAtInnerSide = UnitUtil.ScaleLength(treadLengthAtInnerSide);
                }

                if (m_TreadLengthAtInnerSide <= 0)
                {
                    m_TreadLengthAtInnerSide = UnitUtil.ScaleLength(stairs.ActualTreadDepth);
                }
            }
            else
            {
                valid = false;
            }

            // Get override from parameter
            double treadLengthAtInnerSideOverride = 0.0;

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.RevitParameterName, out treadLengthAtInnerSideOverride) != null ||
                ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.CompatibleRevitParameterName, out treadLengthAtInnerSideOverride) != null)
            {
                m_TreadLengthAtInnerSide = UnitUtil.ScaleArea(treadLengthAtInnerSideOverride);
            }

            return(valid);
        }
        /// <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, EntryMap entryMap)
        {
            bool valid = true;

            if (StairsExporter.IsLegacyStairs(element))
            {
                double riserHeight, treadLength, treadLengthAtInnerSide, nosingLength, waistThickness = 0;
                int    numberOfRisers, numberOfTreads = 0;
                ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element,
                                                           out numberOfRisers, out numberOfTreads,
                                                           out riserHeight, out treadLength, out treadLengthAtInnerSide,
                                                           out nosingLength, out waistThickness);
                m_TreadLengthAtOffset = treadLength;
            }
            else if (element is Stairs)
            {
                Stairs stairs = element as Stairs;
                m_TreadLengthAtOffset = UnitUtil.ScaleLength(stairs.ActualTreadDepth);
            }
            else if (element is StairsRun)
            {
                StairsRun stairsRun = element as StairsRun;
                Stairs    stairs    = stairsRun.GetStairs();
                m_TreadLengthAtOffset = UnitUtil.ScaleLength(stairs.ActualTreadDepth);
            }
            else
            {
                valid = false;
            }

            // Get override from parameter
            double treadLengthAtOffset = 0.0;

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.RevitParameterName, out treadLengthAtOffset) != null ||
                ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.CompatibleRevitParameterName, out treadLengthAtOffset) != null)
            {
                m_TreadLengthAtOffset = UnitUtil.ScaleArea(treadLengthAtOffset);
            }

            return(valid);
        }
        /// <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, treadLengthAtInnerSide, nosingLength, waistThickness = 0;
                int    numberOfRisers, numberOfTreads = 0;
                ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element,
                                                           out numberOfRisers, out numberOfTreads,
                                                           out riserHeight, out m_TreadLength, out treadLengthAtInnerSide,
                                                           out nosingLength, out waistThickness);
            }
            else if (element is Stairs)
            {
                Stairs stairs = element as Stairs;
                m_TreadLength = UnitUtil.ScaleLength(stairs.ActualTreadDepth);
            }
            else if (element is StairsRun)
            {
                StairsRun     stairsRun     = element as StairsRun;
                StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType;
                Stairs        stairs        = stairsRun.GetStairs();

                m_TreadLength = UnitUtil.ScaleLength(stairs.ActualTreadDepth);
            }
            else
            {
                valid = false;
            }

            // Get override from parameter
            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, "TreadLength", out m_TreadLength) != null)
            {
                m_TreadLength = UnitUtil.ScaleArea(m_TreadLength);
            }

            return(valid);
        }
        /// <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 (CurrentElement != element)
            {
                CurrentElement = element;
                if (StairsExporter.IsLegacyStairs(element))
                {
                    int    numberOfRisers, numberOfTreads;
                    double riserHeight, treadLength, treadLengthAtInnerSide, nosingLength, waistThickness;

                    ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element,
                                                               out numberOfRisers, out numberOfTreads,
                                                               out riserHeight, out treadLength, out treadLengthAtInnerSide,
                                                               out nosingLength, out waistThickness);

                    NumberOfRisers         = numberOfRisers;
                    NumberOfTreads         = numberOfTreads;
                    RiserHeight            = riserHeight;
                    TreadLength            = treadLength;
                    TreadLengthAtInnerSide = treadLengthAtInnerSide;
                    NosingLength           = nosingLength;
                    WaistThickness         = waistThickness;

                    TreadLengthAtOffset = TreadLength;
                    WalkingLineOffset   = WaistThickness / 2.0;
                }
                else if (element is Stairs)
                {
                    Stairs stairs = element as Stairs;
                    NumberOfRisers = stairs.ActualRisersNumber;
                    NumberOfTreads = stairs.ActualTreadsNumber;
                    RiserHeight    = UnitUtil.ScaleLength(stairs.ActualRiserHeight);
                    TreadLength    = UnitUtil.ScaleLength(stairs.ActualTreadDepth);
                }
                else if (element is StairsRun)
                {
                    StairsRun     stairsRun     = element as StairsRun;
                    StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType;
                    Stairs        stairs        = stairsRun.GetStairs();
                    StairsType    stairsType    = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType;

                    NumberOfRisers      = stairs.ActualRisersNumber;
                    NumberOfTreads      = stairs.ActualTreadsNumber;
                    RiserHeight         = UnitUtil.ScaleLength(stairs.ActualRiserHeight);
                    TreadLength         = UnitUtil.ScaleLength(stairs.ActualTreadDepth);
                    TreadLengthAtOffset = TreadLength;
                    NosingLength        = UnitUtil.ScaleLength(stairsRunType.NosingLength);
                    WaistThickness      = UnitUtil.ScaleLength(stairsRun.ActualRunWidth);
                    WalkingLineOffset   = WaistThickness / 2.0;

                    double treadLengthAtInnerSide;
                    if (ParameterUtil.GetDoubleValueFromElement(stairsType,
                                                                BuiltInParameter.STAIRSTYPE_MINIMUM_TREAD_WIDTH_INSIDE_BOUNDARY, out treadLengthAtInnerSide) != null)
                    {
                        TreadLengthAtInnerSide = UnitUtil.ScaleLength(treadLengthAtInnerSide);
                    }
                    else
                    {
                        TreadLengthAtInnerSide = 0.0;
                    }
                }
                else
                {
                    valid = false;
                }
            }
            return(valid);
        }
Example #6
0
        public static Level GetLevelOfElement(Element elem, Document doc)
        {
            ElementId levId = elem.LevelId;

            if (levId == ElementId.InvalidElementId)
            {
                Parameter levParam = elem.get_Parameter(BuiltInParameter.SCHEDULE_LEVEL_PARAM);
                if (levParam != null)
                {
                    levId = levParam.AsElementId();
                }
            }

            if (levId == ElementId.InvalidElementId)
            {
                Parameter levParam = elem.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM);
                if (levParam != null)
                {
                    levId = levParam.AsElementId();
                }
            }

            if (levId == ElementId.InvalidElementId)
            {
                Parameter levParam = elem.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM);
                if (levParam != null)
                {
                    levId = levParam.AsElementId();
                }
            }

            if (levId == ElementId.InvalidElementId && elem is StairsRun)
            {
                StairsRun run = elem as StairsRun;
                if (run != null)
                {
                    Stairs    stair    = run.GetStairs();
                    Parameter levParam = stair.get_Parameter(BuiltInParameter.STAIRS_BASE_LEVEL_PARAM);
                    if (levParam != null)
                    {
                        levId = levParam.AsElementId();
                    }
                }
            }

            if (levId == ElementId.InvalidElementId)
            {
                List <Solid> solids = GeometryUtils.GetSolidsFromElement(elem);
                if (solids.Count == 0)
                {
                    return(null);
                }
                XYZ[] maxmin   = GeometryUtils.GetMaxMinHeightPoints(solids);
                XYZ   minPoint = maxmin[1];
                levId = GetNearestLevel(minPoint, doc);
            }

            if (levId == ElementId.InvalidElementId)
            {
                throw new Exception("Не удалось получить уровень у элемента " + elem.Id.IntegerValue.ToString());
            }

            Level lev = doc.GetElement(levId) as Level;

            return(lev);
        }