diff --git a/CS/CurvedStairsRunComponent.cs b/CS/CurvedStairsRunComponent.cs
deleted file mode 100644
index f2923bb..0000000
--- a/CS/CurvedStairsRunComponent.cs
+++ /dev/null
@@ -1,243 +0,0 @@
-//
-// (C) Copyright 2003-2017 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 System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Architecture;
-
-namespace Revit.SDK.Samples.StairsAutomation.CS
-{
- ///
- /// A stairs component consisting of a single curved run.
- ///
- class CurvedStairsRunComponent : TransformedStairsComponent, IStairsRunComponent
- {
- ///
- /// Creates a new CurvedStairsRunConfiguration at the default location and orientation.
- ///
- /// The number of risers in the run.
- /// The bottom elevation.
- /// The desired tread depth.
- /// The width.
- /// The radius of the innermost edge of the run.
- /// The Revit API application creation object.
- public CurvedStairsRunComponent(int riserNumber, double bottomElevation,
- double desiredTreadDepth, double width,
- double innerRadius, Autodesk.Revit.Creation.Application appCreate) :
- base()
- {
- m_riserNumber = riserNumber;
- m_bottomElevation = bottomElevation;
- m_innerRadius = innerRadius;
- m_outerRadius = innerRadius + width;
- m_incrementAngle = desiredTreadDepth / (m_innerRadius + width / 2.0);
- m_desiredTreadDepth = desiredTreadDepth;
- m_includedAngle = m_incrementAngle * (riserNumber - 1);
-
- m_center = new XYZ(0, 0, bottomElevation);
- m_appCreate = appCreate;
- }
-
- ///
- /// Creates a new CurvedStairsRunConfiguration at the specified location and orientation.
- ///
- /// The number of risers in the run.
- /// The bottom elevation.
- /// The desired tread depth.
- /// The width.
- /// The radius of the innermost edge of the run.
- /// The Revit API application creation object.
- /// The transformation (location and orientation).
- public CurvedStairsRunComponent(int riserNumber, double bottomElevation,
- double desiredTreadDepth, double width,
- double innerRadius, Autodesk.Revit.Creation.Application appCreate,
- Transform transform) :
- base(transform)
- {
- m_riserNumber = riserNumber;
- m_bottomElevation = bottomElevation;
- m_innerRadius = innerRadius;
- m_outerRadius = innerRadius + width;
- m_incrementAngle = desiredTreadDepth / (m_innerRadius + width / 2.0);
- m_includedAngle = m_incrementAngle * (riserNumber - 1);
- m_desiredTreadDepth = desiredTreadDepth;
- m_center = new XYZ(0, 0, bottomElevation);
- m_appCreate = appCreate;
- }
-
- private int m_riserNumber;
- private double m_bottomElevation;
- private double m_innerRadius;
- private double m_outerRadius;
- private double m_incrementAngle;
- private double m_includedAngle;
- private double m_desiredTreadDepth;
- private XYZ m_center;
- private Autodesk.Revit.Creation.Application m_appCreate;
- private StairsRun m_stairsRun;
-
- #region IStairsRunConfiguration members
-
- ///
- /// Implements the interface property.
- ///
- public double RunElevation
- {
- get
- {
- return m_bottomElevation;
- }
- }
-
- ///
- /// Implements the interface property.
- ///
- public double TopElevation
- {
- get
- {
- if (m_stairsRun == null)
- {
- throw new NotSupportedException("Stairs run hasn't been constructed yet.");
- }
- return m_stairsRun.TopElevation;
- }
- }
-
- ///
- /// Implements the interface method.
- ///
- public IList GetStairsPath()
- {
- if (m_stairsRun == null)
- {
- throw new NotSupportedException("Stairs run hasn't been constructed yet.");
- }
- CurveLoop curveLoop = m_stairsRun.GetStairsPath();
- return curveLoop.ToList();
- }
-
- ///
- /// Implements the interface method.
- ///
- public Curve GetFirstCurve()
- {
- return GetEndCurve(false);
- }
-
- ///
- /// Implements the interface method.
- ///
- public Curve GetLastCurve()
- {
- return GetEndCurve(true);
- }
-
- ///
- /// Implements the interface method.
- ///
- public XYZ GetRunEndpoint()
- {
- return GetLastCurve().GetEndPoint(0);
- }
-
- ///
- /// Implements the interface property.
- ///
- private double Radius
- {
- get
- {
- return (m_innerRadius + m_outerRadius) / 2.0;
- }
- }
-
- ///
- /// Implements the interface method.
- ///
- public Autodesk.Revit.DB.Architecture.StairsRun CreateStairsRun(Document document, ElementId stairsId)
- {
- m_stairsRun = StairsRun.CreateSpiralRun(document, stairsId, TransformPoint(m_center),
- Radius, 0, m_includedAngle, true, StairsRunJustification.Center);
- Width = m_outerRadius - m_innerRadius;
- document.Regenerate(); // to get updated width
- return m_stairsRun;
- }
-
- ///
- /// Implements the interface property.
- ///
- public double Width
- {
- get
- {
- return m_outerRadius - m_innerRadius;
- }
- set
- {
- m_outerRadius = value + m_innerRadius;
- if (m_stairsRun != null)
- {
- m_stairsRun.ActualRunWidth = m_outerRadius - m_innerRadius;
- m_incrementAngle = m_desiredTreadDepth / (m_innerRadius + value / 2.0);
- }
- }
- }
- #endregion
-
- ///
- /// Gets the first or last riser curve of the run.
- ///
- /// True to get the last curve, false to get the first.
- /// The curve.
- private Curve GetEndCurve(bool last)
- {
- if (m_stairsRun == null)
- {
- throw new NotSupportedException("Stairs run hasn't been constructed yet.");
- }
-
- // Obtain the footprint boundary
- CurveLoop boundary = m_stairsRun.GetFootprintBoundary();
-
- // Obtain the endpoint of the stairs path matching the desired end,
- // and find out which curve contains this point.
- CurveLoop path = m_stairsRun.GetStairsPath();
- Curve pathCurve = path.First();
- XYZ pathPoint = pathCurve.GetEndPoint(last ? 1 : 0);
-
- foreach (Curve boundaryCurve in boundary)
- {
- if (boundaryCurve.Project(pathPoint).XYZPoint.IsAlmostEqualTo(pathPoint))
- {
- return boundaryCurve;
- }
- }
-
- throw new Exception("Unable to find an intersecting boundary curve in the run.");
- }
-
- }
-}
diff --git a/CS/IStairsRunComponent.cs b/CS/IStairsRunComponent.cs
deleted file mode 100644
index 469b05a..0000000
--- a/CS/IStairsRunComponent.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-//
-// (C) Copyright 2003-2017 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 System.Collections.Generic;
-using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Architecture;
-
-namespace Revit.SDK.Samples.StairsAutomation.CS
-{
- ///
- /// The base interface for a single stairs run.
- ///
- public interface IStairsRunComponent
- {
- ///
- /// Causes the run to be created.
- ///
- /// The stairs must be properly set in the stairs edit mode, with an open transaction.
- /// The document.
- /// The stairs id.
- /// The new stairs run.
- StairsRun CreateStairsRun(Document document, ElementId stairsId);
-
- ///
- /// The bottom elevation of the run.
- ///
- double RunElevation
- {
- get;
- }
-
- ///
- /// The top elevation of the run.
- ///
- /// Thrown if the stairs run has not been created, and this cannot be calculated without it.
- double TopElevation
- {
- get;
- }
-
- ///
- /// The width of the run.
- ///
- double Width
- {
- get;
- set;
- }
-
- ///
- /// Gets the path of the stairs run.
- ///
- /// This is not guaranteed to succeed if the run has not been created.
- /// The stairs path.
- /// Thrown if the stairs run has not been created, and this cannot be calculated without it.
- IList GetStairsPath();
-
- ///
- /// Gets the first tread line for the run.
- ///
- /// This is not guaranteed to succeed if the run has not been created.
- /// The first curve.
- /// Thrown if the stairs run has not been created, and this cannot be calculated without it.
- Curve GetFirstCurve();
-
- ///
- /// Gets the last tread line for the run.
- ///
- /// This is not guaranteed to succeed if the run has not been created.
- /// The last curve.
- /// Thrown if the stairs run has not been created, and this cannot be calculated without it.
- Curve GetLastCurve();
-
- ///
- /// Gets the endpoint of the run for purposes of locating the next run.
- ///
- /// If the run "start point" is the lower left corner of the two dimensional projection of the run, this is the "upper right".
- /// This is not guaranteed to succeed if the run has not been created.
- /// The endpoint.
- /// Thrown if the stairs run has not been created, and this cannot be calculated without it.
- XYZ GetRunEndpoint();
- }
-}
diff --git a/CS/SketchedCurvedStairsRunComponent.cs b/CS/SketchedCurvedStairsRunComponent.cs
deleted file mode 100644
index 46c75d3..0000000
--- a/CS/SketchedCurvedStairsRunComponent.cs
+++ /dev/null
@@ -1,252 +0,0 @@
-//
-// (C) Copyright 2003-2017 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 System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Architecture;
-
-namespace Revit.SDK.Samples.StairsAutomation.CS
-{
- ///
- /// A stairs run consisting of a single sketched curved run.
- ///
- /// Because this is sketched, the maximum covered angle for the stair is 360 degrees.
- class SketchedCurvedStairsRunComponent : TransformedStairsComponent, IStairsRunComponent
- {
-
- ///
- /// Creates a new SketchedCurvedStairsRunConfiguration at the default location and orientation.
- ///
- /// The number of risers in the run.
- /// The bottom elevation.
- /// The desired tread depth.
- /// The width.
- /// The radius of the innermost edge of the run.
- /// The Revit API application creation object.
- public SketchedCurvedStairsRunComponent(int riserNumber, double bottomElevation,
- double desiredTreadDepth, double width,
- double innerRadius, Autodesk.Revit.Creation.Application appCreate) :
- base()
- {
- m_riserNumber = riserNumber;
- m_bottomElevation = bottomElevation;
- m_innerRadius = innerRadius;
- m_outerRadius = innerRadius + width;
- m_incrementAngle = desiredTreadDepth / (m_innerRadius + width / 2.0);
- m_includedAngle = m_incrementAngle * (riserNumber - 1);
- if (m_includedAngle > 2 * Math.PI)
- throw new Exception("Arguments provided require an included angle of more than 360 degrees");
-
- m_center = new XYZ(0, 0, bottomElevation);
- m_appCreate = appCreate;
- }
-
- ///
- /// Creates a new SketchedCurvedStairsRunConfiguration at the specified location and orientation.
- ///
- /// The number of risers in the run.
- /// The bottom elevation.
- /// The desired tread depth.
- /// The width.
- /// The radius of the innermost edge of the run.
- /// The Revit API application creation object.
- /// The transformation (location and orientation).
- public SketchedCurvedStairsRunComponent(int riserNumber, double bottomElevation,
- double desiredTreadDepth, double width,
- double innerRadius, Autodesk.Revit.Creation.Application appCreate,
- Transform transform) :
- base(transform)
- {
- m_riserNumber = riserNumber;
- m_bottomElevation = bottomElevation;
- m_innerRadius = innerRadius;
- m_outerRadius = innerRadius + width;
- m_incrementAngle = desiredTreadDepth / (m_innerRadius + width / 2.0);
- m_includedAngle = m_incrementAngle * (riserNumber - 1);
- if (m_includedAngle > 2 * Math.PI)
- throw new Exception("Arguments provided require an included angle of more than 360 degrees");
-
- m_center = new XYZ(0, 0, bottomElevation);
- m_appCreate = appCreate;
- }
-
- private int m_riserNumber;
- private double m_bottomElevation;
- private double m_innerRadius;
- private double m_outerRadius;
- private double m_incrementAngle;
- private double m_includedAngle;
- private XYZ m_center;
- private Autodesk.Revit.Creation.Application m_appCreate;
- private StairsRun m_stairsRun;
-
- #region IStairsConfiguration members
- ///
- /// Implements the interface property.
- ///
- public double RunElevation
- {
- get
- {
- return m_bottomElevation;
- }
- }
-
- ///
- /// Implements the interface property.
- ///
- public double TopElevation
- {
- get
- {
- if (m_stairsRun == null)
- {
- throw new NotSupportedException("Stairs run hasn't been constructed yet.");
- }
- return m_stairsRun.TopElevation;
- }
- }
-
- ///
- /// Implements the interface method.
- ///
- public double GetRunElevation()
- {
- return m_bottomElevation;
- }
-
- ///
- /// Implements the interface method.
- ///
- public IList GetStairsPath()
- {
- List ret = new List();
- Arc arc = Arc.Create(m_center, (m_innerRadius + m_outerRadius) / 2.0, 0, m_includedAngle, XYZ.BasisX, XYZ.BasisY);
- ret.Add(arc);
-
- return ret;
- }
-
- ///
- /// Implements the interface method.
- ///
- public Curve GetFirstCurve()
- {
- return GetRunRiserCurves().First();
- }
-
- ///
- /// Implements the interface method.
- ///
- public Curve GetLastCurve()
- {
- return GetRunRiserCurves().Last();
- }
-
- ///
- /// Implements the interface method.
- ///
- public IList GetRunRiserCurves()
- {
- double incAngle = 0.0;
- XYZ center = XYZ.Zero;
- List ret = new List();
-
- // Run riser curves are linear and radial with respect to the center of curvature.
- for (int i = 0; i < m_riserNumber - 1; i++)
- {
- XYZ start = center + new XYZ(m_innerRadius * Math.Cos(incAngle), m_innerRadius * Math.Sin(incAngle), 0);
- XYZ end = center + new XYZ(m_outerRadius * Math.Cos(incAngle), m_outerRadius * Math.Sin(incAngle), 0);
- ret.Add(Line.CreateBound(start, end));
-
- incAngle += m_incrementAngle;
- }
-
- // last one handled manually to ensure that it intersects end curves
- IList boundaryCurves = GetRunBoundaryCurves();
-
- ret.Add(Line.CreateBound(boundaryCurves[0].Evaluate(1.0, true), boundaryCurves[1].Evaluate(1.0, true)));
-
- return ret;
- }
-
- ///
- /// Implements the interface method.
- ///
- public XYZ GetRunEndpoint()
- {
- return GetRunBoundaryCurves()[1].GetEndPoint(1);
- }
-
- ///
- /// Implements the interface method.
- ///
- public IList GetRunBoundaryCurves()
- {
- List ret = new List();
- Arc arc = Arc.Create(m_center, m_innerRadius, 0, m_includedAngle, XYZ.BasisX, XYZ.BasisY);
- ret.Add(arc);
-
- arc = Arc.Create(m_center, m_outerRadius, 0, m_includedAngle, XYZ.BasisX, XYZ.BasisY);
- ret.Add(arc);
-
- return ret;
- }
-
- ///
- /// Implements the interface method.
- ///
- public Autodesk.Revit.DB.Architecture.StairsRun CreateStairsRun(Document document, ElementId stairsId)
- {
- m_stairsRun = StairsRun.CreateSketchedRun(document, stairsId, GetRunElevation(),
- Transform(GetRunBoundaryCurves()), Transform(GetRunRiserCurves()),
- Transform(GetStairsPath()));
- document.Regenerate();
- return m_stairsRun;
- }
-
- ///
- /// Implements the interface property.
- ///
- public double Width
- {
- get
- {
- return m_outerRadius - m_innerRadius;
- }
- set
- {
- if (m_stairsRun != null)
- {
- throw new InvalidOperationException("Cannot change width of already existing sketched run.");
- }
- m_outerRadius = value + m_innerRadius;
- }
- }
-
- #endregion
-
- }
-}
diff --git a/CS/SketchedStraightStairsRunComponent.cs b/CS/SketchedStraightStairsRunComponent.cs
deleted file mode 100644
index 37de754..0000000
--- a/CS/SketchedStraightStairsRunComponent.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-//
-// (C) Copyright 2003-2017 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 System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Architecture;
-
-namespace Revit.SDK.Samples.StairsAutomation.CS
-{
- ///
- /// A stairs run consisting of a single sketched straight run.
- ///
- public class SketchedStraightStairsRunComponent : TransformedStairsComponent, IStairsRunComponent
- {
- ///
- /// Creates a new sketched run configuration at the default location and orientation.
- ///
- /// Stairs run boundary curves can be calculated before the run is created.
- /// The number of risers.
- /// The bottom elevation.
- /// The desired tread depth.
- /// The width of the run.
- public SketchedStraightStairsRunComponent(int riserNumber, double bottomElevation, double desiredTreadDepth, double width):
- base()
- {
- m_riserNumber = riserNumber;
- m_bottomElevation = bottomElevation;
- m_desiredTreadDepth = desiredTreadDepth;
- m_width = width;
- m_runExtent = new XYZ(0, (riserNumber - 1) * desiredTreadDepth, 0);
- m_widthOffset = new XYZ(m_width, 0, 0);
- }
-
- ///
- /// Creates a new sketched run configuration at the specified location and orientation.
- ///
- /// The number of risers.
- /// The bottom elevation.
- /// The desired tread depth.
- /// The width of the run.
- /// The transform (location and orientation).
- public SketchedStraightStairsRunComponent(int riserNumber, double bottomElevation, double desiredTreadDepth, double width, Transform transform):
- base(transform)
- {
- m_riserNumber = riserNumber;
- m_bottomElevation = bottomElevation;
- m_desiredTreadDepth = desiredTreadDepth;
- m_width = width;
- // This is the full extent of the run across all treads
- m_runExtent = new XYZ(0, (riserNumber - 1) * desiredTreadDepth, 0);
- m_widthOffset = new XYZ(m_width, 0, 0);
- }
-
-
- private int m_riserNumber;
- private double m_bottomElevation;
- private double m_desiredTreadDepth;
- private double m_width;
- private XYZ m_runExtent;
- private XYZ m_widthOffset;
- private StairsRun m_stairsRun;
-
- #region IStairsRunConfiguration members
-
- ///
- /// Implements the interface property.
- ///
- public double RunElevation
- {
- get
- {
- return m_bottomElevation;
- }
- }
-
- ///
- /// Implements the interface property.
- ///
- public double TopElevation
- {
- get
- {
- if (m_stairsRun == null)
- {
- throw new NotSupportedException("Stairs run hasn't been constructed yet.");
- }
- return m_stairsRun.TopElevation;
- }
- }
-
- ///
- /// Implements the interface method.
- ///
- public double GetRunElevation()
- {
- return m_bottomElevation;
- }
-
- ///
- /// Implements the interface method.
- ///
- public IList GetStairsPath()
- {
- // Proceed up the middle of the run to the run extent
- XYZ start = new XYZ(m_width / 2.0, 0, m_bottomElevation);
- XYZ end = start + m_runExtent;
- Line curve1 = Line.CreateBound(start, end);
-
- List ret = new List();
- ret.Add(curve1);
- return Transform(ret);
- }
-
- ///
- /// Implements the interface method.
- ///
- public Curve GetFirstCurve()
- {
- return GenerateRunRiserCurves().First();
- }
-
- ///
- /// Implements the interface method.
- ///
- public Curve GetLastCurve()
- {
- return GenerateRunRiserCurves().Last();
- }
-
- ///
- /// Implements the interface method.
- ///
- public XYZ GetRunEndpoint()
- {
- return GetLastCurve().GetEndPoint(1);
- }
-
- ///
- /// Implements the interface method.
- ///
- public IList GetRunBoundaryCurves()
- {
- return Transform(GenerateUntransformedRunBoundaryCurves());
- }
-
- ///
- /// Implements the interface method.
- ///
- public Autodesk.Revit.DB.Architecture.StairsRun CreateStairsRun(Document document, ElementId stairsId)
- {
- m_stairsRun = StairsRun.CreateSketchedRun(document, stairsId, GetRunElevation(),
- GetRunBoundaryCurves(), GenerateRunRiserCurves(),
- GetStairsPath());
- document.Regenerate();
-
- return m_stairsRun;
- }
-
- ///
- /// Implements the interface property.
- ///
- public double Width
- {
- get
- {
- return m_width;
- }
- set
- {
- if (m_stairsRun != null)
- {
- throw new InvalidOperationException("Cannot change width of sketched run.");
- }
- m_width = value;
- }
- }
- #endregion
-
- ///
- /// Generates the run boundary curves (not transformed by the stored transformation).
- ///
- ///
- private IList GenerateUntransformedRunBoundaryCurves()
- {
- // Start at 0, 0 and extend to the run extent
- XYZ start = new XYZ(0, 0, m_bottomElevation);
- XYZ end = start + m_runExtent;
- Line curve1 = Line.CreateBound(start, end);
-
- List ret = new List();
- ret.Add(curve1);
-
- // Start offset along the width and extend to the run extent
- start = new XYZ(m_width, 0, m_bottomElevation);
- end = start + m_runExtent;
- Line curve2 = Line.CreateBound(start, end);
- ret.Add(curve2);
-
- return ret;
- }
-
- ///
- /// Generates the riser curves for the sketch.
- ///
- ///
- private IList GenerateRunRiserCurves()
- {
- List ret = new List();
-
- // Generate all curves but the last by incrementing along the tread depth
- for (int i = 0; i < m_riserNumber - 1; i++)
- {
- XYZ start = new XYZ(0, i * m_desiredTreadDepth, m_bottomElevation);
- XYZ end = start + m_widthOffset;
-
- ret.Add(Line.CreateBound(start, end));
- }
-
- // last one handled manually to ensure that it intersects the endpoints of the stairs curves
- // Untransformed curves are used because transformation happens below
- IList boundaryCurves = GenerateUntransformedRunBoundaryCurves();
-
- ret.Add(Line.CreateBound(boundaryCurves[0].Evaluate(1.0, true), boundaryCurves[1].Evaluate(1.0, true)));
-
- return Transform(ret);
- }
- }
-}
diff --git a/CS/StraightStairsRunComponent.cs b/CS/StraightStairsRunComponent.cs
deleted file mode 100644
index 8cec413..0000000
--- a/CS/StraightStairsRunComponent.cs
+++ /dev/null
@@ -1,233 +0,0 @@
-//
-// (C) Copyright 2003-2017 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 System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Architecture;
-
-namespace Revit.SDK.Samples.StairsAutomation.CS
-{
- ///
- /// A stairs run consisting of a linear straight run.
- ///
- public class StraightStairsRunComponent : TransformedStairsComponent, IStairsRunComponent
- {
- ///
- /// Creates a new straight stairs run in the default location and orientation.
- ///
- /// The number of risers.
- /// The bottom elevation of the run.
- /// The desired tread depth.
- /// The width of the run.
- public StraightStairsRunComponent(int riserNumber, double bottomElevation, double desiredTreadDepth, double width):
- base()
- {
- m_riserNumber = riserNumber;
- m_bottomElevation = bottomElevation;
- m_desiredTreadDepth = desiredTreadDepth;
- m_width = width;
- m_runOffset = new XYZ(0, (riserNumber - 1) * desiredTreadDepth, 0);
- m_widthOffset = new XYZ(m_width, 0, 0);
- }
-
- ///
- /// Creates a new straight stairs run in the specified location and orientation.
- ///
- /// The number of risers.
- /// The bottom elevation of the run.
- /// The desired tread depth.
- /// The width of the run.
- /// The transform (orientation and location) for the run.
- public StraightStairsRunComponent(int riserNumber, double bottomElevation, double desiredTreadDepth, double width,
- Transform transform):
- base (transform)
- {
- m_riserNumber = riserNumber;
- m_bottomElevation = bottomElevation;
- m_desiredTreadDepth = desiredTreadDepth;
- m_width = width;
- m_runOffset = new XYZ(0, (riserNumber - 1) * desiredTreadDepth, 0);
- m_widthOffset = new XYZ(m_width, 0, 0);
- }
-
- private int m_riserNumber;
- private double m_bottomElevation;
- private double m_desiredTreadDepth;
- private double m_width;
- private XYZ m_runOffset;
- private XYZ m_widthOffset;
- private StairsRun m_stairsRun = null;
-
- #region IStairsRunConfiguration Members
-
- ///
- /// Implements the interface method.
- ///
- public double GetRunElevation()
- {
- return m_bottomElevation;
- }
-
- ///
- /// Implements the interface method.
- ///
- public Line GetRunStairsPath()
- {
- XYZ start = new XYZ(m_width / 2.0, 0, m_bottomElevation);
- XYZ end = start + m_runOffset;
- Line curve1 = Line.CreateBound(start, end);
-
- return curve1;
- }
-
- ///
- /// Implements the interface method.
- ///
- public double RunElevation
- {
- get
- {
- return m_bottomElevation;
- }
- }
-
- ///
- /// Implements the interface method.
- ///
- public double TopElevation
- {
- get
- {
- if (m_stairsRun == null)
- {
- throw new NotSupportedException("Stairs run hasn't been constructed yet.");
- }
- return m_stairsRun.TopElevation;
- }
- }
-
- ///
- /// Implements the interface method.
- ///
- public IList GetStairsPath()
- {
- if (m_stairsRun == null)
- {
- throw new NotSupportedException("Stairs run hasn't been constructed yet.");
- }
- CurveLoop curveLoop = m_stairsRun.GetStairsPath();
- return curveLoop.ToList();
- }
-
- ///
- /// Implements the interface method.
- ///
- public Curve GetFirstCurve()
- {
- return GetEndCurve(false);
- }
-
- ///
- /// Implements the interface method.
- ///
- public Curve GetLastCurve()
- {
- return GetEndCurve(true);
- }
-
- ///
- /// Implements the interface method.
- ///
- public XYZ GetRunEndpoint()
- {
- return GetLastCurve().GetEndPoint(0);
- }
-
- ///
- /// Implements the interface method.
- ///
- public Autodesk.Revit.DB.Architecture.StairsRun CreateStairsRun(Document document, ElementId stairsId)
- {
- m_stairsRun = StairsRun.CreateStraightRun(document, stairsId,
- Transform(GetRunStairsPath()), StairsRunJustification.Center);
- Width = m_width;
- document.Regenerate(); // to get updated width
- return m_stairsRun;
- }
-
- ///
- /// Implements the interface property.
- ///
- public double Width
- {
- get
- {
- return m_width;
- }
- set
- {
- m_width = value;
- if (m_stairsRun != null)
- {
- m_stairsRun.ActualRunWidth = m_width;
- }
- }
- }
-
- #endregion
-
- ///
- /// Gets the first or last riser curve of the run.
- ///
- /// True to get the last curve, false to get the first.
- /// The curve.
- private Curve GetEndCurve(bool last)
- {
- if (m_stairsRun == null)
- {
- throw new NotSupportedException("Stairs run hasn't been constructed yet.");
- }
-
- // Obtain the footprint boundary of the run.
- CurveLoop boundary = m_stairsRun.GetFootprintBoundary();
-
- // Find the first or last point on the path
- CurveLoop path = m_stairsRun.GetStairsPath();
- Curve pathCurve = path.First();
- XYZ pathPoint = pathCurve.GetEndPoint(last ? 1 : 0);
-
- // Walk the footprint boundary, and look for a curve whose projection of the target point is equal to the point.
- foreach (Curve boundaryCurve in boundary)
- {
- if (boundaryCurve.Project(pathPoint).XYZPoint.IsAlmostEqualTo(pathPoint))
- {
- return boundaryCurve;
- }
- }
-
- throw new Exception("Unable to find an intersecting boundary curve in the run.");
- }
- }
-}
diff --git a/CS/TransformedStairsComponent.cs b/CS/TransformedStairsComponent.cs
deleted file mode 100644
index be3c73d..0000000
--- a/CS/TransformedStairsComponent.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// (C) Copyright 2003-2017 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 System.Collections.Generic;
-using Autodesk.Revit.DB;
-
-namespace Revit.SDK.Samples.StairsAutomation.CS
-{
- ///
- /// An abstract base class for stairs components which can be moved via a translation and rotation.
- ///
- public class TransformedStairsComponent
- {
- private Transform m_transform;
-
- ///
- /// Constructs a transformed component with the identity transform.
- ///
- public TransformedStairsComponent()
- {
- m_transform = Autodesk.Revit.DB.Transform.Identity;
- }
-
- ///
- /// Constructs a transformed component with the specified transform.
- ///
- public TransformedStairsComponent(Transform transform)
- {
- m_transform = transform;
- }
-
- ///
- /// Transforms the given XYZ point by the stored transform.
- ///
- /// The point.
- /// The transformed point.
- public XYZ TransformPoint(XYZ point)
- {
- XYZ xyz = m_transform.OfPoint(point);
- return xyz;
- }
-
- ///
- /// Transforms the given curve by the stored transform.
- ///
- /// The curve.
- /// The transformed curve.
- public Curve Transform(Curve curve)
- {
- return GeometryUtils.TransformCurve(curve, m_transform);
- }
-
- ///
- /// Transforms the given line by the stored transform.
- ///
- /// The line.
- /// The transformed line.
- public Line Transform(Line line)
- {
- return Transform(line as Curve) as Line;
- }
-
- ///
- /// Transforms all members of the given curve array by the stored transform.
- ///
- /// The input curves.
- /// The transformed curves.
- public IList Transform(IList inputs)
- {
- return GeometryUtils.TransformCurves(inputs, m_transform);
- }
- }
-}