/* ============================================================================== * 功能描述:SpaceExtension * 创 建 者:Garrett * 创建日期:2019/6/26 17:40:25 * ==============================================================================*/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.DB; using Autodesk.Revit.DB.Mechanical; using SAGA.RevitUtils; using SAGA.RevitUtils.Extends; namespace RevitToJBim.Extension { /// /// SpaceExtension /// public static class SpaceExtension { public readonly static string UseablePhaseName = "阶段1"; /// /// 获取系统使用的阶段Id /// /// /// public static ElementId GetUsePhaseId(this Document doc) { var phase = GetUsePhase(doc); if (phase == null) { return ElementId.InvalidElementId; } return phase.Id; } /// /// 获取系统使用的阶段 /// /// /// public static Phase GetUsePhase(this Document doc) { var elements = doc.GetElements(BuiltInCategory.OST_Phases); foreach (var element in elements) { var tempName = element.Name.Replace(" ", "").Trim(); if (UseablePhaseName == tempName) { return element; } } return null; } public static ElementId GetCurrentPhaseId(this Space space) { return space.GetParameterElementId(BuiltInParameter.ROOM_PHASE_ID) ?? ElementId.InvalidElementId; } /// /// 判断是否是阶段1的空间 /// /// /// public static bool IsPhase1Space(this Space space) { var doc = space.Document; var useId = GetUsePhaseId(doc); return space.GetCurrentPhaseId() == useId; } /// /// 空间标高是否是当前使用视图标高 /// /// /// public static bool IsViewLevel(this Space space) { var doc = space.Document; var useViewId = doc.GetUseView(); if (useViewId == null) { return false; } return space.Level?.Id == useViewId.GenLevel?.Id; } } }