using Autodesk.Revit.DB; using System; namespace Sai.Toolkit.Revit.Helpers { public static class BuiltEnumDictionary { #if REVIT2025 public static string ToLabel(this ForgeTypeId source) { if (ParameterUtils.IsBuiltInParameter(source)) return LabelUtils.GetLabelForBuiltInParameter(source); if (ParameterUtils.IsBuiltInGroup(source)) return LabelUtils.GetLabelForGroup(source); if (UnitUtils.IsUnit(source)) return LabelUtils.GetLabelForUnit(source); if (UnitUtils.IsSymbol(source)) return LabelUtils.GetLabelForSymbol(source); if (SpecUtils.IsSpec(source)) return LabelUtils.GetLabelForSpec(source); return LabelUtils.GetLabelForDiscipline(source); } #endif public static Dictionary GetBuiltInDictionary() where T : Enum { var dict = new Dictionary(); foreach (object enumItem in Enum.GetValues(typeof(T))) { string name = string.Empty; switch (enumItem) { #if REVIT2020 case BuiltInCategory category: name = LabelUtils.GetLabelFor(category); break; #endif case BuiltInParameter param: name = LabelUtils.GetLabelFor(param); break; #if REVIT2018 || REVIT2020 case ParameterType type: name = LabelUtils.GetLabelFor(type); break; case BuiltInParameterGroup group: name = LabelUtils.GetLabelFor(group); break; case UnitType unitType: name = LabelUtils.GetLabelFor(unitType); break; case DisplayUnitType displayUnitType: name = LabelUtils.GetLabelFor(displayUnitType); break; case UnitSymbolType symbolType: name = LabelUtils.GetLabelFor(symbolType); break; #endif case ElementType elementType: name = elementType.Name; break; case Element element: name = element.Name; break; } #if REVIT2025 if (enumItem is ForgeTypeId forgeTypeId) { var label = LabelUtils.GetLabelForBuiltInParameter(forgeTypeId); } #endif dict.Add((T)enumItem, name); } return dict; } } }