Revit API中的楼梯元素(Stairs)讲解

Stairs类表示Revit中的楼梯元素,并包含踏板、立板、楼层数量以及楼梯高度、基座和顶部高程的信息。 楼梯类的方法可用于获得楼梯相关组件,包括楼梯支撑。

以下示例按组件来查找所有楼梯,并将每个楼梯上的某些信息输出到任务对话框。 请注意,此示例使用带有BuiltInCategory.OST_Stairs的类别过滤器,它将返回所有楼梯的ElementIds。

private Stairs GetStairInfo(Document document)
{
    Stairs stairs = null;

    FilteredElementCollector collector = new FilteredElementCollector(document);
    ICollection<ElementId> 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);
}

Runs:

以下示例获取每个Stairs的runs,并确保它开始和结束的状态。

private void AddStartandEndRisers(Stairs stairs)
{
    ICollection<ElementId> 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<ElementId> 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:

landings是StairsLanding类的代表。 以下示例查找Stairs对象的每个landings的厚度。

private void GetStairLandings(Stairs stairs)
{
    ICollection<ElementId> 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的厚度。

Supports:

Revit API不会公开获取Supports的类。 当获得Stairs,StairsRun或StairsLanding的Supports时,这个Supports将会继承于Revit Elements。

以下示例演示获取Stairs对象的所有Supports的名称。

private void GetStairSupports(Stairs stairs)
{
    ICollection<ElementId> 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);
}

=========【更多高级应用请关注公众号】========

 

===================================

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值