123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using Autodesk.Revit.DB;
- using Autodesk.Revit.DB.Mechanical;
- using RevitToJBim.Common;
- using RevitToJBim.MBI;
- using SAGA.RevitUtils.Extends;
- namespace RevitToJBim.Extension
- {
-
-
-
- public static class ElementExtension
- {
- public static string GetFamilyName(this Element element)
- {
- return element.GetFamily()?.Name;
- }
- public static string GetFamilySymbolName(this Element element)
- {
- return element.GetFamilySymbol()?.Name;
- }
-
-
-
-
-
- public static string GetFamilyCode(this Element element)
- {
- string code = "";
- if (element is FamilyInstance fi)
- {
- string familyName = fi.GetFamilyName();
- if (familyName == null) return code;
-
- int index = familyName.IndexOf('-');
- if (index != -1 && index + 1 != familyName.Length)
- code = familyName.Substring(0, familyName.IndexOf('-'));
-
- code = code.Trim();
- }
- return code;
- }
-
-
-
-
-
-
- public static bool IsEquipment(this Element element)
- {
- bool result = false;
- if (element is FamilyInstance fi)
- {
- var family = fi.GetFamilyName();
- result = Regex.IsMatch(family, $"{MBIRegexPattern.IsEquip}");
- }
- return result;
- }
-
-
-
-
-
- public static bool IsEquipmentPart(this Element element)
- {
- bool result = false;
- if (element is FamilyInstance fi)
- {
- var family = fi.GetFamilyName();
- result = Regex.IsMatch(family, $"{MBIRegexPattern.IsEquipPart}");
- }
- return result;
- }
-
-
-
-
-
- public static bool IsBeacon(this Element elem)
- {
- var family = elem.GetFamilyName();
- return family != null && (Regex.IsMatch(family, MBIRegexPattern.IsBeacon));
- }
-
-
-
-
-
-
-
- public static bool IsSpace(this Element elem, bool ischeckzero = true)
- {
- var isspace = false;
- if (elem is Space space)
- {
-
- isspace = !ischeckzero || !(space.IsDeleteSpace());
- string id = space.Id.ToString();
-
- if (isspace)
- {
-
- isspace = space.IsPhase1Space();
- }
- if (isspace)
- {
- isspace = space.IsViewLevel();
- }
- }
- return isspace;
- }
- }
- }
|