// // (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 an L-shape winder and consists of two straight runs and one winder corner. /// class LWinder : Winder { /// /// Number of straight steps at start. /// public uint NumStepsAtStart { get; set; } /// /// Number of straight steps at end. /// public uint NumStepsAtEnd { get; set; } /// /// Number of winder steps in corner. /// public uint NumStepsInCorner { get; set; } /// /// CenterPoint Offset distance from the first inner boundary line of the corner. /// public double CenterOffsetE { get; set; } /// /// CenterPoint Offset distance from the second inner boundary line of the corner. /// public double CenterOffsetF { get; set; } /// /// Three points to determine the L-shape of the stairs. /// public override IList ControlPoints { get { return base.ControlPoints; } set { if (value.Count != 3) { throw new ArgumentException("The control points count must be 3 for LWinder."); } base.ControlPoints = value; } } #region PRIVATE /// /// Winder Corner, connecting the first and the second straight runs. /// private WinderSinglePoint m_corner; /// /// The first straight run at start. /// private WinderStraight m_straightAtStart; /// /// The second straight run at end. /// private WinderStraight m_straightAtEnd; /// /// This method constructs the winder corner and two straight runs. /// Please be sure the input properties being set properly before calling this method. /// private void Construct() { // // Construct the winder corner. // XYZ dir1 = (ControlPoints[1] - ControlPoints[0]).Normalize(); XYZ dir2 = (ControlPoints[2] - ControlPoints[1]).Normalize(); m_corner = new WinderSinglePoint(ControlPoints[1], dir1, dir2, NumStepsInCorner); m_corner.Construct(RunWidth, CenterOffsetE, CenterOffsetF); // // Construct two straight runs to connect to the winder corner. // XYZ startPnt = m_corner.StartPoint - TreadDepth * NumStepsAtStart * dir1; XYZ endPnt = m_corner.EndPoint + TreadDepth * NumStepsAtEnd * dir2; XYZ bisectDir = (dir2 - dir1).Normalize(); XYZ perpendicularDir1 = new XYZ(-dir1.Y, dir1.X, 0); XYZ perpendicularDir2 = new XYZ(-dir2.Y, dir2.X, 0); if (bisectDir.DotProduct(perpendicularDir1) < 0) { perpendicularDir1 = perpendicularDir1.Negate(); perpendicularDir2 = perpendicularDir2.Negate(); } m_straightAtStart = new WinderStraight( startPnt, m_corner.StartPoint, perpendicularDir1, NumStepsAtStart); m_straightAtEnd = new WinderStraight( m_corner.EndPoint, endPnt, perpendicularDir2, NumStepsAtEnd); } #endregion /// /// This method generates the sketch for L-shape winder stairs. /// protected override void GenerateSketch() { // Instantiate the corner and the two straight runs. Construct(); // Generate sketch for winder corner and straight runs. m_straightAtStart.GenerateSketch( RunWidth, OuterBoundary, CenterWalkpath, InnerBoundary, RiserLines); m_corner.GenerateSketch( RunWidth, OuterBoundary, CenterWalkpath, InnerBoundary, RiserLines); m_straightAtEnd.GenerateSketch( RunWidth, OuterBoundary, CenterWalkpath, InnerBoundary, RiserLines); } } }