Stairs Components

Stairs Components

The Stairs class represents a stairs element in Revit and contains properties that represent information about the treads, risers, number of stories, as well as the height of the stairs and base and top elevation. Methods of the Stairs class can be used to get the stairs landing components, stairs run components and stairs supports.

The following example finds all of the Stairs that are by component and outputs some information on each of the Stairs to a Task Dialog. Note that this example uses a category filter with the BuiltInCategory.OST_Stairs which will return ElementIds for all stairs, therefore requiring a test to see if each ElementId represents a Stairs By Component before being cast to a Stairs class when retrieved from the document.

Code Region: Getting stairs information

private Stairs GetStairInfo(Document document)
{
    Stairs stairs = null;

    FilteredElementCollector collector = new FilteredElementCollector(document);
    ICollection<ElementId> stairsIds = collector.WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Stairs).ToElementIdsElementId();
    foreach (ElementId stairId in stairsIds)
    {
        if (Stairs.IsByComponent(document, stairId) == true)
        {
            stairs = document.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;
            
            // Show the information to the user.
            TaskDialog.Show("Revit", info);
        }
    }
  
    return stairs;
}

The StairsType class represents the type for a Stairs element. It contains information about the Stairs, such as the type of all runs and landings in the stairs object, types and offsets for supports on the left, right and middle of the stairs, and numerous other properties related to stair generation such as the maximum height of each riser on the stair element. The following example gets the StairsType for a Stairs element and displays some information about it in a TaskDialog.

Code Region: Getting StairsType Info

private void GetStairsType(Stairs stairs)
{
    StairsType stairsType = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType;

    // Format stairs type info for display
    string info = "Stairs Type:  " + stairsType.Name;
    info += "\nLeft Lateral Offset:  " + stairsType.LeftLateralOffset;
    info += "\nRight Lateral Offset:  " + stairsType.RightLateralOffset;
    info += "\nMax Riser Height:  " + stairsType.MaxRiserHeight;
    info += "\nMin Run Width:  " + stairsType.MinRunWidth;

    TaskDialog.Show("Revit", info);
}

Runs

Stairs by component are composed of runs, landings and supports. Each of these items can be retrieved from the Stairs class. A run is represented in the Revit API by the StairsRun class. The following example gets each run for a Stairs object and makes sure that it begins and ends with a riser.

Code Region: Working with StairsRun

private void AddStartandEndRisers(Stairs stairs)
{
    ICollection<ElementId> runIds = stairs.GetStairsRuns();
            
    foreach (ElementId runId in runIds)
    {
        StairsRun run = stairs.Document.GetElement(runId) as StairsRun;
        if (null != run)
        {
            run.BeginsWithRiser = true;
            run.EndsWithRiser = true;
        }
    }
}

The StairsRun class provides access to run properties such as the StairsRunStyle (straight, winder, etc.), BaseElevation, TopElevation, and properties about the risers. There are also methods in the StairsRun class to access the supports hosted by the run, either all, or just those on the left or right side of the run boundaries. The GetStairsPath() method will return the curves representing the stairs path on the run, which are projected onto the base level of the stairs. The GetFootprintBoundary() method returns the run's boundary curves which are also projected onto the stairs' base level.

There are three static methods of the StairsRun class for creating new runs. These are covered in the Creating and Editing Stairs section.

The StairsRunType class represents the type of a StairsRun. It contains many properties about the treads and risers of the run as well as other information about the run. The following example gets the StairsRunType for the first run in a Stairs element and displays the riser and tread thicknesses along with the type's name.

Code Region: Getting StairsRunType Info

private void GetRunType(Stairs stairs)
{
    ICollection<ElementId> runIds = stairs.GetStairsRuns();

    ElementId firstRunId = runIds.First();

    StairsRun firstRun = stairs.Document.GetElement(firstRunId) as StairsRun;
    if (null != firstRun)
    {
        StairsRunType runType = stairs.Document.GetElement(firstRun.GetTypeId()) as StairsRunType;
        // Format landing type info for display
        string info = "Stairs Run Type:  " + runType.Name;
        info += "\nRiser Thickness:  " + runType.RiserThickness;
        info += "\nTread Thickness:  " + runType.TreadThickness;

        TaskDialog.Show("Revit", info);
    }
}

Landings

Landings are represented by the StairsLanding class. The following example finds the thickness for each landing of a Stairs object.

Code Region: Working with StairsLanding

private void GetStairLandings(Stairs stairs)
{
    ICollection<ElementId> landingIds = stairs.GetStairsLandings();
    string info = "Number of landings:  " + landingIds.Count;

    int landingIndex = 0;
    foreach (ElementId landingId in landingIds)
    {
        landingIndex++;
        StairsLanding landing = stairs.Document.GetElement(landingId) as StairsLanding;
        if (null != landing)
        {
            info += "\nThickness of Landing " + landingIndex + ":  " + landing.Thickness;
        }
    }

    TaskDialog.Show("Revit", info);
}

Similar to StairsRun, StairsLanding has a GetStairsPath() method which returns the curves representing the stairs path on the landing projected onto the base level of the stairs and a GetFootprintBoundary() method which returns the landing's boundary curves, also projected onto the stairs' base level. Also similar to StairsRun, there is a method to get all of the supports hosted by the landing.

The StairsLanding class has a method to create a new landing between two runs. It is covered in the Creating and Editing Stairs section.

The StairsLandingType class represents a landing type in the Revit API. The StairsLandingType class has only a couple of properties specific to it, namely IsMonolithic which is true if the stairs landing is monolithic, and Thickness, representing the thickness of the stairs landing.

StairsComponentConnection

Both StairsRun and StairsLanding have a GetConnections() method which provides information about connections among stairs components (run to run, or run to landing). The method returns a collection of StairsComponentConnection objects which have properties about each connection, including the connection type (to a landing, the start of a stairs run, or the end of a stairs run) and the Id of the connected stairs component.

Supports

The Revit API does not expose a class for stairs supports. When getting the supports for Stairs, StairsRun, or a StairsLanding, the supports will be generic Revit Elements. The following example gets the names of all the supports for a Stairs object.

Code Region: Getting Stairs Supports

private void GetStairSupports(Stairs stairs)
{
    ICollection<ElementId> supportIds = stairs.GetStairsSupports();
    string info = "Number of supports:  " + supportIds.Count;

    int supportIndex = 0;
    foreach (ElementId supportId in supportIds)
    {
        supportIndex++;
        Element support = stairs.Document.GetElement(supportId);
        if (null != support)
        {
            info += "\nName of support " + supportIndex + ":  " + support.Name;
        }
    }

    TaskDialog.Show("Revit", info);
}