Revit API之StairsPath(樓梯路徑)講解

樓梯路徑(StairsPath類)可用於註釋樓梯的傾斜方向和行走線。 靜態方法StairsPath.Create()將爲指定樓梯創建一個新的樓梯路徑,並在特定平面視圖中指定樓梯路徑類型,其中樓梯必須可見。

在Revit UI中編輯樓梯路徑時,StairsPath類具有相關屬性,例如用於設置向上和向下文本的屬性或是否應顯示文本。 另外,可以指定向上和向下文本的偏移量,以及從樓梯中心線到樓梯路徑的偏移量。

以下示例在項目中查找StairsPathType和FloorPlan,並使用它們爲給定的Stairs創建新的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();
}

 

一個StairsPath有一個StairsPathType(樓梯路徑類型)。 樓梯路徑類型可從2個預定義系統系列中獲得:自動向上/向下方向和固定向上方向。 這兩種類型的屬性同樣可用作StairsPathType類中的屬性,例如FullStepArrow和DistanceToCutMark。

CutMarkType類表示Revit UI中的剪切標記類型,它具有表示在UI中編輯剪切標記類型時可用的屬性,例如CutLineAngle和CutLineExtension。 它與StairsType對象相關聯,可以使用BuiltInParameter STAIRSTYPE_CUTMARK_TYPE進行檢索,如下所示。

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;
}

 

=========【更多高級應用請關注公衆號】========

 

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章