样式demo

This commit is contained in:
GG Z
2025-12-28 11:47:54 +08:00
parent ceccab9abb
commit 1fd8d2ced7
65 changed files with 2369 additions and 799 deletions

View File

@@ -0,0 +1,29 @@
using Autodesk.Revit.DB;
namespace ShrlAlgoToolkit.Revit.Extensions;
public static class CategoryExtension
{
public static Element ToElement(this ElementId elementId, Document doc)
{
return doc.GetElement(elementId);
}
public static Category ToCategory(this BuiltInCategory builtInCategory, Document doc)
{
return Category.GetCategory(doc, builtInCategory);
}
public static BuiltInCategory ToBuiltInCategory(this Category category)
{
#if REVIT2018 || REVIT2020
var builtInCategory = (BuiltInCategory)category.Id.IntegerValue;
#elif REVIT2025
var builtInCategory = (BuiltInCategory)category.Id.Value;
#endif
return Enum.IsDefined(typeof(BuiltInCategory), builtInCategory)
? builtInCategory
: throw new ArgumentNullException(nameof(category), "不存在该内建类别");
}
}