Download Revit 2014 Platform API Developers Guidelines
Transcript
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
1. private void CreateStairsPath(Document document, Stairs stairs)
2. {
3.
Transaction transNewPath = new Transaction(document, "New Stairs Path");
4.
transNewPath.Start();
5.
6.
// Find StairsPathType
7.
FilteredElementCollector collector = new FilteredElementCollector(document);
8.
ICollection<ElementId> stairsPathIds = collector.OfClass(typeof(StairsPathType)).ToElementIdsElementId();
9.
10.
// Find a FloorPlan
11.
ElementId planViewId = ElementId.InvalidElementId;
12.
FilteredElementCollector viewCollector = new FilteredElementCollector(document);
13.
ICollection<ElementId> viewIds = viewCollector.OfClass(typeof(View)).ToElementIdsElementId();
14.
foreach (ElementId viewId in viewIds)
15.
{
16.
View view = document.GetElement(viewId) as View;
17.
if (view.ViewType == ViewType.FloorPlan)
18.
{
19.
planViewId = view.Id;
20.
break;
21.
}
22.
}
23.
24.
LinkElementId stairsLinkId = new LinkElementId(stairs.Id);
25.
StairsPath.Create(stairs.Document, stairsLinkId, stairsPathIds.First(), planViewId);
26.
transNewPath.Commit();
27. }
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.