diff --git a/src/Libraries/RevitNodes/Elements/Category.cs b/src/Libraries/RevitNodes/Elements/Category.cs index 2ace1691d7..6158986faf 100644 --- a/src/Libraries/RevitNodes/Elements/Category.cs +++ b/src/Libraries/RevitNodes/Elements/Category.cs @@ -113,7 +113,28 @@ public static Category ById(long id) throw new ArgumentException(Properties.Resources.InvalidCategory); } } + /// + /// Gets Revit Built-in category from current document based on category Id + /// + /// Category Id as ElementId + /// Category if present in current document. + [IsVisibleInDynamoLibrary(false)] + public static Category ById(ElementId categoryId) + { + try + { + var document = DocumentManager.Instance.CurrentDBDocument; + Autodesk.Revit.DB.Category category = Autodesk.Revit.DB.Category.GetCategory(document, categoryId); + if(null == category) + throw new ArgumentException(Properties.Resources.InvalidCategory); + return new Category(category); + } + catch + { + throw new ArgumentException(Properties.Resources.InvalidCategory); + } + } #endregion public override string ToString()