Skip to content

Commit

Permalink
fixed #387
Browse files Browse the repository at this point in the history
  • Loading branch information
andydandy74 committed Nov 11, 2023
1 parent 5265f0f commit e7f76d1
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions nodes/2.x/python/Element.Category+.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,38 @@
def GetCategory(item):
if not item: return None, None
objtype = item.GetType().ToString()
if objtype == "Autodesk.Revit.DB.ParameterFilterElement": return [GetCategoryObjects(x) for x in item.GetCategories()]
elif objtype == "Autodesk.Revit.DB.ViewSchedule": return GetCategoryObjects(item.Definition.CategoryId)
elif objtype == "Autodesk.Revit.DB.Family": return GetCategoryObjects(item.FamilyCategoryId)
elif objtype == "Autodesk.Revit.DB.GraphicsStyle": return GetCategoryObjects(item.GraphicsStyleCategory.Id)
returnID = None
returnIDs = None
returnCat = None
returnBic = None
if objtype == "Autodesk.Revit.DB.ParameterFilterElement": returnIDs = item.GetCategories()
elif objtype == "Autodesk.Revit.DB.ViewSchedule": returnID = item.Definition.CategoryId
elif objtype == "Autodesk.Revit.DB.Family": returnID = item.FamilyCategoryId
elif objtype == "Autodesk.Revit.DB.GraphicsStyle": returnID = item.GraphicsStyleCategory.Id
elif objtype == "Revit.Application.Document":
if item.IsFamilyDocument:
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
return GetCategoryObjects(DocumentManager.Instance.CurrentDBDocument.OwnerFamily.FamilyCategoryId)
else: return None, None
returnID = DocumentManager.Instance.CurrentDBDocument.OwnerFamily.FamilyCategoryId
elif objtype == "Autodesk.Revit.DB.Category":
if item.Parent: return GetCategoryObjects(item.Parent.Id)
else: return None, None
if item.Parent: returnID = item.Parent.Id
elif hasattr(item, "Category"):
if item.Category: return GetCategoryObjects(item.Category.Id)
else: return None, None
else: return None, None

def GetCategoryObjects(catID):
if not catID: return None, None
returnBic = System.Enum.ToObject(BuiltInCategory, catID.IntegerValue)
try: returnCat = Revit.Elements.Category.ById(catID.IntegerValue)
except: returnCat = None
if item.Category: returnID = item.Category.Id
if returnID:
returnBic = System.Enum.ToObject(BuiltInCategory, returnID.IntegerValue)
try: returnCat = Revit.Elements.Category.ById(returnID.IntegerValue)
except: pass
elif returnIDs:
returnCat = []
returnBic = []
for returnID in returnIDs:
returnBic.append(System.Enum.ToObject(BuiltInCategory, returnID.IntegerValue))
try: returnCat.append(Revit.Elements.Category.ById(returnID.IntegerValue))
except: returnCat.append(None)
returnCat.sort()
return returnCat, returnBic


items = UnwrapElement(IN[0])

if isinstance(IN[0], list): OUT = map(list, zip(*[GetCategory(x) for x in items]))
Expand Down

0 comments on commit e7f76d1

Please sign in to comment.