Stairs类表示Revit中的楼梯元素,并包含踏板、立板、楼层数量以及楼梯高度、基座和顶部高程的信息。 楼梯类的方法可用于获得楼梯相关组件,包括楼梯支撑。
以下示例按组件来查找所有楼梯,并将每个楼梯上的某些信息输出到任务对话框。 请注意,此示例使用带有BuiltInCategory.OST_Stairs的类别过滤器,它将返回所有楼梯的ElementIds。
private Stairs GetStairInfo(Document document)
{
Stairs stairs = null;
FilteredElementCollector collector = new FilteredElementCollector(document);
ICollection 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;
}
StairsType类表示Stairs元素的类型。 它包含有关楼梯的信息,例如楼梯中所有runs and landings ,楼梯左,中、右的支撑类型和偏移,以及与与生成楼梯时相关的属性,例如最大高度、踏步高度等。
以下示例通过获取Stairs元素的StairsType,并在TaskDialog中显示有关它的一些信息。
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);
}
以下示例获取每个Stairs的runs,并确保它开始和结束的状态。
private void AddStartandEndRisers(Stairs stairs)
{
ICollection 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;
}
}
}
private void GetRunType(Stairs stairs)
{
ICollection 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是StairsLanding类的代表。 以下示例查找Stairs对象的每个landings的厚度。
private void GetStairLandings(Stairs stairs)
{
ICollection 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);
}
与StairsRun类似,StairsLanding有一个GetStairsPath()方法,它返回表示投影到楼梯底层的平台上的楼梯路径的曲线;GetFootprintBoundary()方表示返回landing边界曲线,也投射到楼梯的基础面上。
StairsLandingType类只有几个特定于它的属性,如IsMonolithic,true表示楼梯landings是单片的;Thickness,表示楼梯landings的厚度。
Revit API不会公开获取Supports的类。 当获得Stairs,StairsRun或StairsLanding的Supports时,这个Supports将会继承于Revit Elements。
以下示例演示获取Stairs对象的所有Supports的名称。
private void GetStairSupports(Stairs stairs)
{
ICollection 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);
}
=========【更多高级应用请关注公众号】========
===================================