RailingCreate(Document, ElementId, ElementId, RailingPlacementPosition) Method |
Automatically creates new railings with the specified railing type on all sides of a stairs or ramp element.
Namespace: Autodesk.Revit.DB.ArchitectureAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic static ICollection<ElementId> Create(
Document document,
ElementId stairsOrRampId,
ElementId railingTypeId,
RailingPlacementPosition placePosition
)
Public Shared Function Create (
document As Document,
stairsOrRampId As ElementId,
railingTypeId As ElementId,
placePosition As RailingPlacementPosition
) As ICollection(Of ElementId)
public:
static ICollection<ElementId^>^ Create(
Document^ document,
ElementId^ stairsOrRampId,
ElementId^ railingTypeId,
RailingPlacementPosition placePosition
)
static member Create :
document : Document *
stairsOrRampId : ElementId *
railingTypeId : ElementId *
placePosition : RailingPlacementPosition -> ICollection<ElementId>
Parameters
- document Document
-
The document.
- stairsOrRampId ElementId
-
The stairs or ramp to which the new railing will host.
The stairs or ramp should have no associated railings yet.
If the stairs are a part of MultistoryStairs element railings will be populated on all levels.
- railingTypeId ElementId
-
The railing type of the new railing to be created.
- placePosition RailingPlacementPosition
-
The placement position of the new railing.
Return Value
ICollectionElementId
The new railing instances successfully created on the stairs.
ExceptionsException | Condition |
---|
ArgumentException |
The stairsOrRampId is not a stairs or ramp element.
-or-
The railingTypeId is not a railing type.
|
ArgumentNullException |
A non-optional argument was null
|
ArgumentOutOfRangeException |
A value passed for an enumeration argument is not a member of that enumeration
|
InvalidOperationException |
The stairsOrRampId already has associated railings or is in editing mode so association of railings is not permitted.
|
ModificationForbiddenException |
The document is in failure mode: an operation has failed,
and Revit requires the user to either cancel the operation
or fix the problem (usually by deleting certain elements).
-or-
The document is being loaded, or is in the midst of another
sensitive process.
|
ModificationOutsideTransactionException |
The document has no open transaction.
|
Exampleprivate void CreateRailing(Document document, Stairs stairs)
{
using (Transaction trans = new Transaction(document, "Create Railings"))
{
trans.Start();
ICollection<ElementId> railingIds = stairs.GetAssociatedRailings();
foreach (ElementId railingId in railingIds)
{
document.Delete(railingId);
}
FilteredElementCollector collector = new FilteredElementCollector(document);
ICollection<ElementId> RailingTypeIds = collector.OfClass(typeof(RailingType)).ToElementIds();
Railing.Create(document, stairs.Id, RailingTypeIds.First(), RailingPlacementPosition.Treads);
trans.Commit();
}
}
Private Sub CreateRailing(document As Document, stairs As Stairs)
Using trans As New Transaction(document, "Create Railings")
trans.Start()
Dim railingIds As ICollection(Of ElementId) = stairs.GetAssociatedRailings()
For Each railingId As ElementId In railingIds
document.Delete(railingId)
Next
Dim collector As New FilteredElementCollector(document)
Dim RailingTypeIds As ICollection(Of ElementId) = collector.OfClass(GetType(RailingType)).ToElementIds()
Railing.Create(document, stairs.Id, RailingTypeIds.First(), RailingPlacementPosition.Treads)
trans.Commit()
End Using
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also