Exemple #1
0
        /// <summary>
        /// Implements the interface method.
        /// </summary>
        public IList <Curve> GetStairsPath()
        {
            if (m_stairsRun == null)
            {
                throw new NotSupportedException("Stairs run hasn't been constructed yet.");
            }
            CurveLoop curveLoop = m_stairsRun.GetStairsPath();

            return(curveLoop.ToList());
        }
Exemple #2
0
        private RevitStairRun StairRunToSpeckle(StairsRun revitStairRun)
        {
            var stairType = Doc.GetElement(revitStairRun.GetTypeId()) as StairsRunType;
            var run       = new RevitStairRun();

            run.family                  = stairType.FamilyName;
            run.type                    = stairType.Name;
            run.risersNumber            = revitStairRun.ActualRisersNumber;
            run.runWidth                = ScaleToSpeckle(revitStairRun.ActualRunWidth);
            run.treadsNumber            = revitStairRun.ActualTreadsNumber;
            run.height                  = ScaleToSpeckle(revitStairRun.Height);
            run.baseElevation           = ScaleToSpeckle(revitStairRun.BaseElevation);
            run.topElevation            = ScaleToSpeckle(revitStairRun.TopElevation);
            run.beginsWithRiser         = revitStairRun.BeginsWithRiser;
            run.endsWithRiser           = revitStairRun.EndsWithRiser;
            run.extensionBelowRiserBase = ScaleToSpeckle(revitStairRun.ExtensionBelowRiserBase);
            run.extensionBelowTreadBase = ScaleToSpeckle(revitStairRun.ExtensionBelowTreadBase);
            run.runStyle                = revitStairRun.StairsRunStyle.ToString();
            run.units                   = ModelUnits;
            run.path                    = CurveLoopToSpeckle(revitStairRun.GetStairsPath());
            run.outline                 = CurveLoopToSpeckle(revitStairRun.GetFootprintBoundary());

            GetAllRevitParamsAndIds(run, revitStairRun);
            return(run);
        }
Exemple #3
0
        /// <summary>
        /// Calculates cross area.
        /// </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)
        {
            double lengthFromParam = 0;

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, "IfcQtyLength", out lengthFromParam) == null)
            {
                ParameterUtil.GetDoubleValueFromElementOrSymbol(element, "Length", out lengthFromParam);
            }
            m_Length = UnitUtil.ScaleLength(lengthFromParam);

            // Check for Stair Run - Do special computation for the length
            if (element is StairsRun)
            {
                StairsRun flight    = element as StairsRun;
                double    flightLen = flight.GetStairsPath().GetExactLength();
                flightLen = UnitUtil.ScaleLength(flightLen);
                if (flightLen > MathUtil.Eps())
                {
                    m_Length = flightLen;
                    return(true);
                }
                // consider override as specified in a parameter
                else if (m_Length > MathUtil.Eps())
                {
                    return(true);
                }
                // exit when none for StairsRun
                else
                {
                    return(false);
                }
            }

            // For others
            if (m_Length > MathUtil.Eps())
            {
                return(true);
            }

            if (extrusionCreationData == null)
            {
                if (ParameterUtil.GetDoubleValueFromElement(element, BuiltInParameter.EXTRUSION_LENGTH, out m_Length) != null)
                {
                    m_Length = UnitUtil.ScaleLength(m_Length);
                }
            }
            else
            {
                m_Length = extrusionCreationData.ScaledLength;
            }

            if (m_Length > MathUtil.Eps())
            {
                return(true);
            }

            return(false);
        }
Exemple #4
0
        public Polygon2D GetStairAreaPolygon(UIDocument currentDocument, Stairs stair, string key)
        {
            ICollection <ElementId> allRunsIds = stair.GetStairsRuns();
            ElementId currentId = allRunsIds.ElementAt(0);

            if (key.Equals(RevitObjectManager.BASE_LEVEL_KEY))
            {
                foreach (ElementId currentBaseId in allRunsIds)
                {
                    StairsRun currentStairsRun  = currentDocument.Document.GetElement(currentBaseId) as StairsRun;
                    StairsRun selectedStairsRun = currentDocument.Document.GetElement(currentId) as StairsRun;

                    if (currentStairsRun.BaseElevation < selectedStairsRun.BaseElevation)
                    {
                        currentId = currentBaseId;
                    }
                }
            }
            else if (key.Equals(RevitObjectManager.TOP_LEVEL_KEY))
            {
                foreach (ElementId currentTopId in allRunsIds)
                {
                    StairsRun currentStairsRun  = currentDocument.Document.GetElement(currentTopId) as StairsRun;
                    StairsRun selectedStairsRun = currentDocument.Document.GetElement(currentId) as StairsRun;

                    if (currentStairsRun.TopElevation > selectedStairsRun.TopElevation)
                    {
                        currentId = currentTopId;
                    }
                }
            }

            List <Vector2D> areaNodes      = new List <Vector2D>();
            StairsRun       finalStairsRun = currentDocument.Document.GetElement(currentId) as StairsRun;
            CurveLoop       stairPath      = finalStairsRun.GetStairsPath();
            Curve           firstStairPathCurve;

            if (stairPath.Count() > 1)
            {
                if ((finalStairsRun.StairsRunStyle.Equals(StairsRunStyle.Winder) || finalStairsRun.StairsRunStyle.Equals(StairsRunStyle.Spiral)) &&
                    key.Equals(RevitObjectManager.TOP_LEVEL_KEY))
                {
                    firstStairPathCurve = stairPath.ElementAt(stairPath.Count() - 1);
                }
                else
                {
                    firstStairPathCurve = stairPath.ElementAt(0);
                }
            }
            else
            {
                firstStairPathCurve = stairPath.ElementAt(0);
            }

            double stairsRunsWidth = ConvertFeetToMeters(finalStairsRun.ActualRunWidth * STAIRS_AREA_SHRINK_FACTOR);

            if (stairsRunsWidth < DEFAULT_AREA_RADIUS)
            {
                stairsRunsWidth = DEFAULT_AREA_RADIUS;
            }

            double pathsLength = ConvertFeetToMeters(firstStairPathCurve.Length * STAIRS_AREA_SHRINK_FACTOR);

            if (pathsLength < DEFAULT_AREA_RADIUS)
            {
                pathsLength = DEFAULT_AREA_RADIUS;
            }

            Vector2D pathsStart    = GeometryFactory.CreateVector2D(ConvertFeetToMeters(firstStairPathCurve.GetEndPoint(0).X), ConvertFeetToMeters(firstStairPathCurve.GetEndPoint(0).Y), MEASUREMENTUNITFACTOR);
            Vector2D pathsEnd      = GeometryFactory.CreateVector2D(ConvertFeetToMeters(firstStairPathCurve.GetEndPoint(1).X), ConvertFeetToMeters(firstStairPathCurve.GetEndPoint(1).Y), MEASUREMENTUNITFACTOR);
            Vector2D pathDirection = pathsEnd.Difference(pathsStart);
            Vector2D pathDirectionPerpenticular = pathDirection.Rotate((-1) * Math.PI / 2).GetAsNormalized();

            Vector2D firstNode = pathsStart.Add(pathDirectionPerpenticular.Multiply(stairsRunsWidth / 2));

            areaNodes.Add(firstNode);
            Vector2D pointToAdd = firstNode.Add(pathDirection);

            areaNodes.Add(pointToAdd);
            pointToAdd = pointToAdd.Add(pathDirectionPerpenticular.Multiply((-1) * stairsRunsWidth));
            areaNodes.Add(pointToAdd);
            pointToAdd = pointToAdd.Add(pathDirection.Multiply(-1));
            areaNodes.Add(pointToAdd);
            areaNodes.Add(firstNode);

            Polygon2D areaPolygon = GeometryFactory.CreatePolygon2D(areaNodes.ToArray(), finalStairsRun.Name);

            return(areaPolygon);
        }
Exemple #5
0
        /// <summary>
        /// Calculates cross area.
        /// </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)
        {
            double lengthFromParam = 0;

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.RevitParameterName, out lengthFromParam) == null)
            {
                if (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.CompatibleRevitParameterName, out lengthFromParam) == null)
                {
                    ParameterUtil.GetDoubleValueFromElementOrSymbol(element, "IfcQtyLength", out lengthFromParam);
                }
            }
            m_Length = UnitUtil.ScaleLength(lengthFromParam);

            // Check for Stair Run - Do special computation for the length
            if (element is StairsRun)
            {
                StairsRun flight    = element as StairsRun;
                double    flightLen = flight.GetStairsPath().GetExactLength();
                flightLen = UnitUtil.ScaleLength(flightLen);
                if (flightLen > MathUtil.Eps())
                {
                    m_Length = flightLen;
                    return(true);
                }
                // consider override as specified in a parameter
                else if (m_Length > MathUtil.Eps())
                {
                    return(true);
                }
                // exit when none for StairsRun
                else
                {
                    return(false);
                }
            }

            // For others
            if (m_Length > MathUtil.Eps())
            {
                return(true);
            }

            if (extrusionCreationData == null)
            {
                if (ParameterUtil.GetDoubleValueFromElement(element, BuiltInParameter.EXTRUSION_LENGTH, out m_Length) != null)
                {
                    m_Length = UnitUtil.ScaleLength(m_Length);
                }
            }
            else
            {
                // For Slab, length is the major edge of the rectangle area profile (get it from ScaledWidth)
                // Also for Stair support
                IFCAnyHandle hnd = ExporterCacheManager.ElementToHandleCache.Find(element.Id);
                if (IFCAnyHandleUtil.IsSubTypeOf(hnd, IFCEntityType.IfcSlab) || element.Category.BuiltInCategory == BuiltInCategory.OST_StairsStringerCarriage)
                {
                    m_Length = extrusionCreationData.ScaledWidth;
                }
                else
                {
                    m_Length = extrusionCreationData.ScaledLength;
                }
            }

            if (m_Length > MathUtil.Eps())
            {
                return(true);
            }

            return(false);
        }