The StairsPath class can be used to annotate the slope direction and walk line of a stair. The static StairsPath.Create() method will create a new stairs path for the specified stairs with the specified stairs path type in a specific plan view in which the stairs must be visible.
The StairsPath class has the same properties that are available in the Properties window when editing a stairs path in the Revit UI, such as properties to set the up and down text along or whether the text should be shown at all. Additionally offsets for the up and down text can be specified as can an offset for the stairs path from the stairs centerline.
The following example finds a StairsPathType and a FloorPlan in the project and uses them to create a new StairsPath for a given Stairs.
Code Region: Create a StairsPath |
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)).ToElementIdsElementId(); // Find a FloorPlan ElementId planViewId = ElementId.InvalidElementId; FilteredElementCollector viewCollector = new FilteredElementCollector(document); ICollection<ElementId> viewIds = viewCollector.OfClass(typeof(View)).ToElementIdsElementId(); 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(); } |
A StairsPath has a StairsPathType. Stair path types are available from 2 predefined system families: Automatic Up/Down Direction and Fixed Up Direction. The properties available for these two types are available as properties in the StairsPathType class, such as FullStepArrow and DistanceToCutMark.
The CutMarkType class represents a cut mark type in the Revit UI and it has properties to represent the same properties available when editing a cut mark type in the UI, such as CutLineAngle and CutLineExtension . It is associated with a StairsType object and can be retrieved using the BuiltInParameter STAIRSTYPE_CUTMARK_TYPE as shown below.
Code Region: Getting the CutMarkType for Stairs |
private CutMarkType GetCutMark(Stairs stairs) { CutMarkType cutMarkType = null; StairsType stairsType = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType; Parameter paramCutMark = stairsType.get_Parameter(BuiltInParameter.STAIRSTYPE_CUTMARK_TYPE); if (paramCutMark.StorageType == StorageType.ElementId) // should be an element id { ElementId cutMarkId = paramCutMark.AsElementId(); cutMarkType = stairs.Document.GetElement(cutMarkId) as CutMarkType; } return cutMarkType; } |