1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
-
- 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
- {
-
-
-
- public static class SpaceExtension
- {
- public readonly static string UseablePhaseName = "阶段1";
-
-
-
-
-
- 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<Phase>(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;
- }
-
-
-
-
-
- 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;
- }
- }
- }
|