/***************************************************/ /**** Private methods ****/ /***************************************************/ private static T ElementType <T>(this IBHoMObject bHoMObject, Document document, IEnumerable <BuiltInCategory> builtInCategories = null) where T : ElementType { string familyName, familyTypeName; bHoMObject.FamilyAndTypeNames(out familyName, out familyTypeName); return(document.ElementType <T>(familyName, familyTypeName, builtInCategories)); }
/***************************************************/ public static ElementType ElementType(this IBHoMObject bHoMObject, Document document, IEnumerable <BuiltInCategory> builtInCategories, RevitSettings settings = null) { if (bHoMObject == null || document == null) { return(null); } settings = settings.DefaultIfNull(); string familyName, familyTypeName; bHoMObject.FamilyAndTypeNames(out familyName, out familyTypeName); if (string.IsNullOrEmpty(familyTypeName)) { return(null); } ElementType elementType = document.ElementType <ElementType>(familyName, familyTypeName, builtInCategories); if (elementType != null) { elementType.Activate(); return(elementType); } //Find ElementType in FamilyLibrary if (settings.FamilyLoadSettings?.FamilyLibrary?.Files != null) { if (builtInCategories != null && builtInCategories.Any(x => x != Autodesk.Revit.DB.BuiltInCategory.INVALID)) { foreach (BuiltInCategory builtInCategory in builtInCategories) { if (builtInCategory == Autodesk.Revit.DB.BuiltInCategory.INVALID) { continue; } FamilySymbol familySymbol = settings.FamilyLoadSettings.LoadFamilySymbol(document, builtInCategory.CategoryName(document), familyName, familyTypeName); if (familySymbol != null) { return(familySymbol); } } } else { return(settings.FamilyLoadSettings.LoadFamilySymbol(document, null, familyName, familyTypeName)); } } return(null); }
/***************************************************/ public static ElementType ElementType(this IBHoMObject bHoMObject, Document document, IEnumerable <BuiltInCategory> builtInCategories, RevitSettings settings = null) { if (bHoMObject == null || document == null) { return(null); } string familyName, familyTypeName; bHoMObject.FamilyAndTypeNames(out familyName, out familyTypeName); return(document.ElementType(familyName, familyTypeName, builtInCategories)); }