// // (C) Copyright 2003-2019 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // using System; using Autodesk.Revit.DB; using System.Collections.Generic; namespace Revit.SDK.Samples.WinderStairs.CS { /// /// It represents a U-shape winder and consists of three straight runs and two winder corners. /// class UWinder : Winder { /// /// Number of straight steps at start. /// public uint NumStepsAtStart { get; set; } /// /// Number of straight steps in middle. /// public uint NumStepsInMiddle { get; set; } /// /// Number of straight steps at end. /// public uint NumStepsAtEnd { get; set; } /// /// Number of winder steps in the first corner. /// public uint NumStepsInCorner1 { get; set; } /// /// CenterPoint Offset distance from the first inner boundary line of the first corner. /// public double CenterOffsetE1 { get; set; } /// /// CenterPoint Offset distance from the second inner boundary line of the first corner. /// public double CenterOffsetF1 { get; set; } /// /// Number of winder steps in the second corner. /// public uint NumStepsInCorner2 { get; set; } /// /// CenterPoint Offset distance from the first inner boundary line of the second corner. /// public double CenterOffsetE2 { get; set; } /// /// CenterPoint Offset distance from the second inner boundary line of the second corner. /// public double CenterOffsetF2 { get; set; } /// /// Four Points to determine the U-shape of the stairs. /// public override IList ControlPoints { get { return base.ControlPoints; } set { if (value.Count != 4) { throw new ArgumentException("The control points count must be 4 for UWinder."); } base.ControlPoints = value; } } #region PRIVATE /// /// The first Winder Corner, connecting the first and the second straight runs. /// private WinderSinglePoint m_corner1st; /// /// The second Winder Corner, connecting the second and the third straight runs. /// private WinderSinglePoint m_corner2nd; /// /// The first straight run at start. /// private WinderStraight m_straightAtStart; /// /// The second straight run in middle. /// private WinderStraight m_straightInMiddle; /// /// The third straight run at end. /// private WinderStraight m_straightAtEnd; /// /// This method constructs two winder corners and three straight runs. /// Please be sure the input properties being set properly before calling this method. /// private void Construct() { // // Construct the first winder corner // XYZ dir1 = (ControlPoints[1] - ControlPoints[0]).Normalize(); XYZ dir2 = (ControlPoints[2] - ControlPoints[1]).Normalize(); m_corner1st = new WinderSinglePoint(ControlPoints[1], dir1, dir2, NumStepsInCorner1); m_corner1st.Construct(RunWidth, CenterOffsetE1, CenterOffsetF1); // // Construct the second winder corner // XYZ dir3 = (ControlPoints[3] - ControlPoints[2]).Normalize(); m_corner2nd = new WinderSinglePoint(ControlPoints[1], dir2, dir3, NumStepsInCorner2); m_corner2nd.Construct(RunWidth, CenterOffsetF2, CenterOffsetE2); XYZ moveDelta = (m_corner1st.Distance2 + m_corner2nd.Distance1 + TreadDepth * NumStepsInMiddle) * dir2; m_corner2nd.Move(moveDelta); // // Construct the three straight runs // XYZ startPnt = m_corner1st.StartPoint - TreadDepth * NumStepsAtStart * dir1; XYZ endPnt = m_corner2nd.EndPoint + TreadDepth * NumStepsAtEnd * dir3; XYZ bisectDir = (dir2 - dir1).Normalize(); XYZ perpendicularDir1 = new XYZ(-dir1.Y, dir1.X, 0); XYZ perpendicularDir2 = new XYZ(-dir2.Y, dir2.X, 0); XYZ perpendicularDir3 = new XYZ(-dir3.Y, dir3.X, 0); if (bisectDir.DotProduct(perpendicularDir1) < 0) { perpendicularDir1 = perpendicularDir1.Negate(); perpendicularDir2 = perpendicularDir2.Negate(); perpendicularDir3 = perpendicularDir3.Negate(); } m_straightAtStart = new WinderStraight( startPnt, m_corner1st.StartPoint, perpendicularDir1, NumStepsAtStart); m_straightInMiddle = new WinderStraight( m_corner1st.EndPoint, m_corner2nd.StartPoint, perpendicularDir2, NumStepsInMiddle); m_straightAtEnd = new WinderStraight( m_corner2nd.EndPoint, endPnt, perpendicularDir3, NumStepsAtEnd); } #endregion /// /// This method generates the sketch for U-shape winder stairs. /// protected override void GenerateSketch() { // Instantiate two winer corners and three straight runs. Construct(); // Generate the sketch for two winder corners and three straight runs. m_straightAtStart.GenerateSketch( RunWidth, OuterBoundary, CenterWalkpath, InnerBoundary, RiserLines); m_corner1st.GenerateSketch( RunWidth, OuterBoundary, CenterWalkpath, InnerBoundary, RiserLines); m_straightInMiddle.GenerateSketch( RunWidth, OuterBoundary, CenterWalkpath, InnerBoundary, RiserLines); m_corner2nd.GenerateSketch( RunWidth, OuterBoundary, CenterWalkpath, InnerBoundary, RiserLines); m_straightAtEnd.GenerateSketch( RunWidth, OuterBoundary, CenterWalkpath, InnerBoundary, RiserLines); } } }