Revit API之StairsPath(楼梯路径)讲解

楼梯路径(StairsPath类)可用于注释楼梯的倾斜方向和行走线。 静态方法StairsPath.Create()将为指定楼梯创建一个新的楼梯路径,并在特定平面视图中指定楼梯路径类型,其中楼梯必须可见。

在Revit UI中编辑楼梯路径时,StairsPath类具有相关属性,例如用于设置向上和向下文本的属性或是否应显示文本。 另外,可以指定向上和向下文本的偏移量,以及从楼梯中心线到楼梯路径的偏移量。

Revit API之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。

Revit API之StairsPath(楼梯路径)讲解

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

 

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

 

Revit API之StairsPath(楼梯路径)讲解

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