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); }
/// <summary> /// Gets the first or last riser curve of the run. /// </summary> /// <param name="last">True to get the last curve, false to get the first.</param> /// <returns>The curve.</returns> 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 <Curve>(); 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."); }
/// <summary> /// Gets the first or last riser curve of the run. /// </summary> /// <param name="last">True to get the last curve, false to get the first.</param> /// <returns>The curve.</returns> 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 <Curve>(); 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."); }