Пример #1
0
 /// <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);
 }
Пример #2
0
        /// <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());
            }
        }