/// <summary> /// Calculates number of risers for a stair. /// </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) { bool valid = true; if (StairsExporter.IsLegacyStairs(element)) { double riserHeight, treadLength, treadLengthAtInnerSide, nosingLength, waistThickness = 0; int numberOfTreads = 0; ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element, out m_NumberOfRisers, out numberOfTreads, out riserHeight, out treadLength, out treadLengthAtInnerSide, out nosingLength, out waistThickness); } else if (element is Stairs) { Stairs stairs = element as Stairs; m_NumberOfRisers = stairs.ActualRisersNumber; } else if (element is StairsRun) { StairsRun stairsRun = element as StairsRun; StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType; m_NumberOfRisers = stairsRun.ActualRisersNumber; } else { valid = false; } // Get override from parameter ParameterUtil.GetIntValueFromElementOrSymbol(element, "NumberOfRiser", out m_NumberOfRisers); return(valid); }
public Result setup_stairs() { // https://help.autodesk.com/cloudhelp/2018/ENU/Revit-API/Revit_API_Developers_Guide/Revit_Geometric_Elements/Stairs_and_Railings/Creating_and_Editing_Stairs.html XYZ stairsline = new XYZ(146 / 12.0, 165 / 12.0, level.Elevation); ElementId newStairsId = null; using (StairsEditScope newStairsScope = new StairsEditScope(doc, "New Stairs")) { newStairsId = newStairsScope.Start(level.Id, level_above.Id); using (Transaction t = new Transaction(doc)) { t.Start("Create window"); Line locationLine = Line.CreateBound( stairsline, stairsline.Add(new XYZ(15, 0, 0))); StairsRun newRun2 = StairsRun.CreateStraightRun(doc, newStairsId, locationLine, StairsRunJustification.Center); // newRun2.ActualRunWidth = 10; t.Commit(); } newStairsScope.Commit(new MyRevit.StairsFailurePreprocessor()); } return(Result.Succeeded); }
/// <summary> /// Calculates number of risers for a stair. /// </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) { bool valid = true; if (m_CurrentElement != element) { double scale = exporterIFC.LinearScale; m_CurrentElement = element; if (StairsExporter.IsLegacyStairs(element)) { ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element, out m_NumberOfRisers, out m_NumberOfTreads, out m_RiserHeight, out m_TreadLength, out m_TreadLengthAtInnerSide, out m_NosingLength, out m_WaistThickness); m_TreadLengthAtOffset = m_TreadLength; m_WalkingLineOffset = m_WaistThickness / 2.0; } else if (element is Stairs) { Stairs stairs = element as Stairs; m_NumberOfRisers = stairs.ActualRisersNumber; m_NumberOfTreads = stairs.ActualTreadsNumber; m_RiserHeight = stairs.ActualRiserHeight * scale; m_TreadLength = stairs.ActualTreadDepth * scale; } else if (element is StairsRun) { StairsRun stairsRun = element as StairsRun; StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType; Stairs stairs = stairsRun.GetStairs(); StairsType stairsType = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType; m_NumberOfRisers = stairs.ActualRisersNumber; m_NumberOfTreads = stairs.ActualTreadsNumber; m_RiserHeight = stairs.ActualRiserHeight * scale; m_TreadLength = stairs.ActualTreadDepth * scale; m_TreadLengthAtOffset = m_TreadLength; m_NosingLength = stairsRunType.NosingLength * scale; m_WaistThickness = stairsRun.ActualRunWidth * scale; m_WalkingLineOffset = m_WaistThickness / 2.0; double treadLengthAtInnerSide; if (ParameterUtil.GetDoubleValueFromElement(stairsType, BuiltInParameter.STAIRSTYPE_MINIMUM_TREAD_WIDTH_INSIDE_BOUNDARY, out treadLengthAtInnerSide) != null) { m_TreadLengthAtInnerSide = treadLengthAtInnerSide * scale; } else { m_TreadLengthAtInnerSide = 0.0; } } else { valid = false; } } return(valid); }
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); }
public void CheckMyStairs(Document doc) { Stairs stair = null; FilteredElementCollector collector = new FilteredElementCollector(doc); ICollection <ElementId> stairsIds = collector.WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Stairs).ToElementIds(); List <double> stairWidthList = new List <double>(); foreach (var stairId in stairsIds) { if (Stairs.IsByComponent(doc, stairId) == true) { stair = doc.GetElement(stairId) as Stairs; //Autodesk.Revit.DB.Architecture.Stairs stair ; StairsRun sRun = doc.GetElement(stair.GetStairsRuns().First()) as StairsRun; double StairWidth = sRun.ActualRunWidth; double StairWidthmm = UnitUtils.ConvertFromInternalUnits(StairWidth, DisplayUnitType.DUT_MILLIMETERS); stairWidthList.Add(StairWidthmm); // string info = "*\nNumber of stories: " + stair.Height; // TaskDialog.Show("Revit", info); } } StreamWriter file = new StreamWriter("Stairs.txt", true); foreach (var item in stairWidthList) { string stairwidthinmm = "Width of stair is {0} mm" + item; file.WriteLine(item); } file.Close(); }
/// <summary> /// Implements the interface method. /// </summary> 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); }
/// <summary> /// Implements the interface method. /// </summary> 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); }
/// <summary> /// Implements the interface method. /// </summary> 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); }
/// <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); }
/// <summary> /// This method creates the sketched run in Revit document. /// </summary> /// <param name="rvtDoc">Revit Document</param> /// <param name="winderRunId">Created winder run</param> private void CreateWinderRun(Document rvtDoc, ref ElementId winderRunId) { using (StairsEditScope stairsMode = new StairsEditScope(rvtDoc, GetType().Name)) { var winderOldRun = rvtDoc.GetElement(winderRunId) as StairsRun; var stairsId = ElementId.InvalidElementId; // Non-existed stairs, create a new one. if (winderOldRun == null) { // Find two levels to create a stairs between them FilteredElementCollector filterLevels = new FilteredElementCollector(rvtDoc); var levels = filterLevels.OfClass(typeof(Level)).ToElements(); List <Element> levelList = new List <Element>(); levelList.AddRange(levels); levelList.Sort((a, b) => { return(((Level)a).Elevation.CompareTo(((Level)b).Elevation)); }); // Start the stairs edit mode stairsId = stairsMode.Start(levelList[0].Id, levelList[1].Id); } else // using the existed stairs { // Start the stairs edit mode stairsId = stairsMode.Start(winderOldRun.GetStairs().Id); } using (Transaction winderTransaction = new Transaction(rvtDoc)) { // Start the winder creation transaction winderTransaction.Start(GetType().Name); // The boundaries is consist of internal and external boundaries. List <Curve> boundarys = new List <Curve>(); boundarys.AddRange(InnerBoundary); boundarys.AddRange(OuterBoundary); // Calculate the run elevation. Stairs stairs = rvtDoc.GetElement(stairsId) as Stairs; double elevation = ControlPoints[0].Z; double actualElevation = Math.Max(elevation, stairs.BaseElevation); // Create the run StairsRun run = StairsRun.CreateSketchedRun(rvtDoc, stairsId, actualElevation, boundarys, RiserLines, CenterWalkpath); if (ElementId.InvalidElementId != winderRunId) { // Delete the old run rvtDoc.Delete(winderRunId); } // output the new run winderRunId = run.Id; // Finish the winder run creation. winderTransaction.Commit(); } // Finish the stairs Edit mode. stairsMode.Commit(new StairsEditScopeFailuresPreprocessor()); } }
/// <summary> /// Calculates number of risers for a stair. /// </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) { bool valid = true; if (StairsExporter.IsLegacyStairs(element)) { double riserHeight, treadLength, nosingLength, waistThickness = 0; int numberOfRisers, numberOfTreads = 0; ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element, out numberOfRisers, out numberOfTreads, out riserHeight, out treadLength, out m_TreadLengthAtInnerSide, out nosingLength, out waistThickness); } else if (element is Stairs || element is StairsRun) { Stairs stairs; if (element is StairsRun) { StairsRun stairsRun = element as StairsRun; stairs = stairsRun.GetStairs(); } else { stairs = element as Stairs; } StairsType stairsType = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType; double treadLengthAtInnerSide; if (ParameterUtil.GetDoubleValueFromElement(stairsType, BuiltInParameter.STAIRSTYPE_MINIMUM_TREAD_WIDTH_INSIDE_BOUNDARY, out treadLengthAtInnerSide) != null) { m_TreadLengthAtInnerSide = UnitUtil.ScaleLength(treadLengthAtInnerSide); } if (m_TreadLengthAtInnerSide <= 0) { m_TreadLengthAtInnerSide = UnitUtil.ScaleLength(stairs.ActualTreadDepth); } } else { valid = false; } // Get override from parameter double treadLengthAtInnerSideOverride = 0.0; if (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.RevitParameterName, out treadLengthAtInnerSideOverride) != null || ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.CompatibleRevitParameterName, out treadLengthAtInnerSideOverride) != null) { m_TreadLengthAtInnerSide = UnitUtil.ScaleArea(treadLengthAtInnerSideOverride); } return(valid); }
/// <summary> /// Calculates number of risers for a stair. /// </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) { bool valid = true; if (StairsExporter.IsLegacyStairs(element)) { double riserHeight, treadLength, treadLengthAtInnerSide, nosingLength, waistThickness = 0; int numberOfRisers, numberOfTreads = 0; ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element, out numberOfRisers, out numberOfTreads, out riserHeight, out treadLength, out treadLengthAtInnerSide, out nosingLength, out waistThickness); m_WalkingLineOffset = waistThickness / 2.0; // !! The waist thickness seems to be wrongly associated with the width of the run! } else if (element is Stairs) { Stairs stairs = element as Stairs; ICollection <ElementId> stairRuns = stairs.GetStairsRuns(); if (stairRuns.Count > 0) { // Get the run width from one of the run/flight to compute the walking line offset StairsRun run = stairs.Document.GetElement(stairRuns.First()) as StairsRun; m_WalkingLineOffset = run.ActualRunWidth / 2.0; } } else if (element is StairsRun) { StairsRun stairsRun = element as StairsRun; StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType; m_WalkingLineOffset = stairsRun.ActualRunWidth / 2.0; } else { valid = false; } // Get override from parameter double walkingLineOffsetOverride = 0.0; if (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.RevitParameterName, out walkingLineOffsetOverride) != null || ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.CompatibleRevitParameterName, out walkingLineOffsetOverride) != null) { m_WalkingLineOffset = UnitUtil.ScaleArea(walkingLineOffsetOverride); } return(valid); }
private static Direction GetDirection(Stairs stair) { ICollection <ElementId> runIds = stair.GetStairsRuns(); StairsRun sr = (StairsRun)_doc.GetElement(runIds.First()); BoundingBoxXYZ bbXYZ = sr.get_BoundingBox(_doc.ActiveView); double lx = bbXYZ.Max.X - bbXYZ.Min.X; double ly = bbXYZ.Max.Y - bbXYZ.Min.Y; if (lx < ly) { return(Direction.Y); } else { return(Direction.X); } }
/// <summary> /// Calculates number of risers for a stair. /// </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) { bool valid = true; if (StairsExporter.IsLegacyStairs(element)) { double riserHeight, treadLength, treadLengthAtInnerSide, nosingLength, waistThickness = 0; int numberOfRisers, numberOfTreads = 0; ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element, out numberOfRisers, out numberOfTreads, out riserHeight, out treadLength, out treadLengthAtInnerSide, out nosingLength, out waistThickness); m_TreadLengthAtOffset = treadLength; } else if (element is Stairs) { Stairs stairs = element as Stairs; m_TreadLengthAtOffset = UnitUtil.ScaleLength(stairs.ActualTreadDepth); } else if (element is StairsRun) { StairsRun stairsRun = element as StairsRun; Stairs stairs = stairsRun.GetStairs(); m_TreadLengthAtOffset = UnitUtil.ScaleLength(stairs.ActualTreadDepth); } else { valid = false; } // Get override from parameter double treadLengthAtOffset = 0.0; if (ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.RevitParameterName, out treadLengthAtOffset) != null || ParameterUtil.GetDoubleValueFromElementOrSymbol(element, entryMap.CompatibleRevitParameterName, out treadLengthAtOffset) != null) { m_TreadLengthAtOffset = UnitUtil.ScaleArea(treadLengthAtOffset); } return(valid); }
/// <summary> /// Calculates number of risers for a stair. /// </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) { bool valid = true; if (StairsExporter.IsLegacyStairs(element)) { double riserHeight, treadLength, treadLengthAtInnerSide, waistThickness = 0; int numberOfRisers, numberOfTreads = 0; ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element, out numberOfRisers, out numberOfTreads, out riserHeight, out treadLength, out treadLengthAtInnerSide, out m_NosingLength, out waistThickness); } else if (element is Stairs) { Stairs stairs = element as Stairs; ICollection <ElementId> stairRuns = stairs.GetStairsRuns(); if (stairRuns.Count > 0) { // Get the run width from one of the run/flight to compute the walking line offset StairsRun run = stairs.Document.GetElement(stairRuns.First()) as StairsRun; StairsRunType stairsRunType = run.Document.GetElement(run.GetTypeId()) as StairsRunType; m_NosingLength = UnitUtil.ScaleLength(stairsRunType.NosingLength); } } else if (element is StairsRun) { StairsRun stairsRun = element as StairsRun; StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType; m_NosingLength = UnitUtil.ScaleLength(stairsRunType.NosingLength); } else { valid = false; } return(valid); }
public static Level GetLevelOfElement(Element elem, Document doc) { ElementId levId = elem.LevelId; if (levId == ElementId.InvalidElementId) { Parameter levParam = elem.get_Parameter(BuiltInParameter.SCHEDULE_LEVEL_PARAM); if (levParam != null) { levId = levParam.AsElementId(); } } if (levId == ElementId.InvalidElementId) { Parameter levParam = elem.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM); if (levParam != null) { levId = levParam.AsElementId(); } } if (levId == ElementId.InvalidElementId) { Parameter levParam = elem.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM); if (levParam != null) { levId = levParam.AsElementId(); } } if (levId == ElementId.InvalidElementId && elem is StairsRun) { StairsRun run = elem as StairsRun; if (run != null) { Stairs stair = run.GetStairs(); Parameter levParam = stair.get_Parameter(BuiltInParameter.STAIRS_BASE_LEVEL_PARAM); if (levParam != null) { levId = levParam.AsElementId(); } } } if (levId == ElementId.InvalidElementId) { List <Solid> solids = GeometryUtils.GetSolidsFromElement(elem); if (solids.Count == 0) { return(null); } XYZ[] maxmin = GeometryUtils.GetMaxMinHeightPoints(solids); XYZ minPoint = maxmin[1]; levId = GetNearestLevel(minPoint, doc); } if (levId == ElementId.InvalidElementId) { throw new Exception("Не удалось получить уровень у элемента " + elem.Id.IntegerValue.ToString()); } Level lev = doc.GetElement(levId) as Level; return(lev); }
public void CheckModelStairs(Document doc, UIDocument uidoc) { Stairs stair = null; FilteredElementCollector collector = new FilteredElementCollector(doc); ICollection <ElementId> stairsIds = collector.WhereElementIsElementType().OfCategory(BuiltInCategory.OST_Stairs).ToElementIds(); foreach (var stairId in stairsIds) { stair = doc.GetElement(stairId) as Stairs; //Autodesk.Revit.DB.Architecture.Stairs stair ; StairsRun sRun = doc.GetElement(stair.GetStairsRuns().First()) as Autodesk.Revit.DB.Architecture.StairsRun; double StairWidth = sRun.ActualRunWidth; /* * var stairrCollector = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)); * stairrCollector.OfCategory(BuiltInCategory.OST_Stairs); * IList<Element> stairList = stairrCollector.ToElements(); * * List<Double> passedStairs = new List<Double>(); * List<Double> failedStairs = new List<Double>(); * List<ElementId> passedStairsId = new List<ElementId>(); * List<ElementId> failedStairsId = new List<ElementId>(); * * foreach (Element mystair in stairList) * { * //Instance param * Parameter parameter = mystair.get_Parameter(BuiltInParameter.STAIRS_RUN_ACTUAL_RUN_WIDTH); * Parameter stairInstparam = parameter; * //string InstStorage = doorInstparam.StorageType.ToString(); * //Parameter parameter = door.LookupParameter("width"); * * double stairInstWidth = (stairInstparam.HasValue) ? stairInstparam.AsDouble() : 0; * //double doorWidthParam = parameter.AsDouble(); * * //type param * ElementId stairTypeId = mystair.GetTypeId(); * ElementType stairType = (ElementType)doc.GetElement(stairTypeId); * Parameter stairTypeParam = stairType.get_Parameter(BuiltInParameter.FAMILY_WIDTH_PARAM); * * //string typeStorage = doorInstparam.StorageType.ToString(); * * double stairTypeWidth = (stairTypeParam.HasValue) ? stairTypeParam.AsDouble() : 0; * * * double stairInstWidthmm = UnitUtils.ConvertFromInternalUnits(stairInstWidth, DisplayUnitType.DUT_MILLIMETERS); * double stairTypeWidthmm = UnitUtils.ConvertFromInternalUnits(stairTypeWidth, DisplayUnitType.DUT_MILLIMETERS); * * double ttldoorWidth = new double(); * if (stairInstWidthmm == 0) * { * ttldoorWidth = stairTypeWidthmm; * } * else * { * ttldoorWidth = stairInstWidthmm; * } * * if (ttldoorWidth <= 800) * { * ElementId failstairId = mystair.GetTypeId(); * failedStairsId.Add(failstairId); * failedStairs.Add(ttldoorWidth); * } * else * { * ElementId passstairId = mystair.GetTypeId(); * passedStairsId.Add(passstairId); * passedStairs.Add(ttldoorWidth); * } * } * * } */ //#region Write to text file StreamWriter File = new StreamWriter("FailedStairs.txt"); // foreach (Double item in failedStairs) //{ File.WriteLine(StairWidth); //} File.Close(); /* * StreamWriter file = new StreamWriter("PassedStairs.txt"); * foreach (Double item in passedStairs) * { * file.WriteLine(item); * } * file.Close(); #endregion * * * /* * Stairs stairs = null; * * FilteredElementCollector collector = new FilteredElementCollector(doc); * ICollection<ElementId> stairsIds = collector.WhereElementIsElementType().OfCategory(BuiltInCategory.OST_Stairs).ToElementIds(); * foreach (ElementId stairId in stairsIds) * { * if (Stairs.IsByComponent(doc, stairId) == true) * { * stairs = doc.GetElement(stairId) as Stairs; * * // Format the information * String info = "\nNumber of stories: " + stairs.NumberOfStories; * info += "\nHeight of stairs: " + stairs.Height; * info += "\nNumber of treads: " + stairs.ActualTreadsNumber; * info += "\nTread depth: " + stairs.ActualTreadDepth; * info += "\nStair width: " + stairs; * * // Show the information to the user. * TaskDialog.Show("Revit", info); * } * } */ // return stairs; } }
/// <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); }
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); }
/// <summary> /// Calculates number of risers for a stair. /// </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) { bool valid = true; if (CurrentElement != element) { CurrentElement = element; if (StairsExporter.IsLegacyStairs(element)) { int numberOfRisers, numberOfTreads; double riserHeight, treadLength, treadLengthAtInnerSide, nosingLength, waistThickness; ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element, out numberOfRisers, out numberOfTreads, out riserHeight, out treadLength, out treadLengthAtInnerSide, out nosingLength, out waistThickness); NumberOfRisers = numberOfRisers; NumberOfTreads = numberOfTreads; RiserHeight = riserHeight; TreadLength = treadLength; TreadLengthAtInnerSide = treadLengthAtInnerSide; NosingLength = nosingLength; WaistThickness = waistThickness; TreadLengthAtOffset = TreadLength; WalkingLineOffset = WaistThickness / 2.0; } else if (element is Stairs) { Stairs stairs = element as Stairs; NumberOfRisers = stairs.ActualRisersNumber; NumberOfTreads = stairs.ActualTreadsNumber; RiserHeight = UnitUtil.ScaleLength(stairs.ActualRiserHeight); TreadLength = UnitUtil.ScaleLength(stairs.ActualTreadDepth); } else if (element is StairsRun) { StairsRun stairsRun = element as StairsRun; StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType; Stairs stairs = stairsRun.GetStairs(); StairsType stairsType = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType; NumberOfRisers = stairs.ActualRisersNumber; NumberOfTreads = stairs.ActualTreadsNumber; RiserHeight = UnitUtil.ScaleLength(stairs.ActualRiserHeight); TreadLength = UnitUtil.ScaleLength(stairs.ActualTreadDepth); TreadLengthAtOffset = TreadLength; NosingLength = UnitUtil.ScaleLength(stairsRunType.NosingLength); WaistThickness = UnitUtil.ScaleLength(stairsRun.ActualRunWidth); WalkingLineOffset = WaistThickness / 2.0; double treadLengthAtInnerSide; if (ParameterUtil.GetDoubleValueFromElement(stairsType, BuiltInParameter.STAIRSTYPE_MINIMUM_TREAD_WIDTH_INSIDE_BOUNDARY, out treadLengthAtInnerSide) != null) { TreadLengthAtInnerSide = UnitUtil.ScaleLength(treadLengthAtInnerSide); } else { TreadLengthAtInnerSide = 0.0; } } else { valid = false; } } return(valid); }