Create Method


Creates a new stairs path for the specified stairs with the specified stairs path type only in the plan view.

Namespace: Autodesk.Revit.DB.Architecture
Assembly: RevitAPI (in RevitAPI.dll) Version: 22.0.0.0 (22.1.0.0)
Since: 2013

Syntax

C#
public static StairsPath Create(
	Document document,
	LinkElementId stairsId,
	ElementId typeId,
	ElementId planViewId
)
Visual Basic
Public Shared Function Create ( _
	document As Document, _
	stairsId As LinkElementId, _
	typeId As ElementId, _
	planViewId As ElementId _
) As StairsPath
Visual C++
public:
static StairsPath^ Create(
	Document^ document, 
	LinkElementId^ stairsId, 
	ElementId^ typeId, 
	ElementId^ planViewId
)

Parameters

document
Type: Autodesk.Revit.DB Document
The document.
stairsId
Type: Autodesk.Revit.DB LinkElementId
The id of the stairs element either in the host document or in a linked document.
typeId
Type: Autodesk.Revit.DB ElementId
The type of stairs path.
planViewId
Type: Autodesk.Revit.DB ElementId
The plan view in which the stairs path will be shown.

Return Value

The new stairs path.

Examples

Copy C#
private void CreateStairsPath(Document document, Stairs stairs)
{
    Transaction transNewPath = new Transaction(document, "New Stairs Path");
    transNewPath.Start();

    // Find StairsPathType
    FilteredElementCollector collector = new FilteredElementCollector(document);
    ICollection<ElementId> stairsPathIds = collector.OfClass(typeof(StairsPathType)).ToElementIds();

    // Find a FloorPlan
    ElementId planViewId = ElementId.InvalidElementId;
    FilteredElementCollector viewCollector = new FilteredElementCollector(document);
    ICollection<ElementId> viewIds = viewCollector.OfClass(typeof(View)).ToElementIds();
    foreach (ElementId viewId in viewIds)
    {
        View view = document.GetElement(viewId) as View;
        if (view.ViewType == ViewType.FloorPlan)
        {
            planViewId = view.Id;
            break;
        }
    }

    LinkElementId stairsLinkId = new LinkElementId(stairs.Id);
    StairsPath.Create(stairs.Document, stairsLinkId, stairsPathIds.First(), planViewId);
    transNewPath.Commit();
}
Copy VB.NET
Private Sub CreateStairsPath(document As Document, stairs As Stairs)
    Dim transNewPath As New Transaction(document, "New Stairs Path")
    transNewPath.Start()

    ' Find StairsPathType
    Dim collector As New FilteredElementCollector(document)
    Dim stairsPathIds As ICollection(Of ElementId) = collector.OfClass(GetType(StairsPathType)).ToElementIds()

    ' Find a FloorPlan
    Dim planViewId As ElementId = ElementId.InvalidElementId
    Dim viewCollector As New FilteredElementCollector(document)
    Dim viewIds As ICollection(Of ElementId) = viewCollector.OfClass(GetType(View)).ToElementIds()
    For Each viewId As ElementId In viewIds
        Dim view As View = TryCast(document.GetElement(viewId), View)
        If view.ViewType = ViewType.FloorPlan Then
            planViewId = view.Id
            Exit For
        End If
    Next

    Dim stairsLinkId As New LinkElementId(stairs.Id)
    StairsPath.Create(stairs.Document, stairsLinkId, stairsPathIds.First(), planViewId)
    transNewPath.Commit()
End Sub

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException The stairsId is not a valid stairs. -or- The typeId is not a valid stairs path type. -or- The planViewId is not a valid plan view. -or- The stairsId already has a stairs path. -or- The stairsId is not visible in planViewId.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was null

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →