List of used Categories

Hello,
Do you know how to make list of used Categories in model?.
I would like to make multicategory selection but when i pick categories which are not used in model then my graph isn’t working. So first i would like to get list of categories in model and then make a multicategory selection.
Thanks for all advices :slight_smile:

@kambed91 ,

i like using active view by default. i can catch any element by that!

# 🎣🎣 Get All Elements in View
items = FilteredElementCollector(doc, doc.ActiveView.Id)\
                             .WhereElementIsNotElementType()\
                             .ToElements()
OUT = items

Hi @Draxl_Andreas thanks for reply.
How can i use this code in dynamo? Do you know any examples which uses codes in node? Im beginner user of dynamo.

Hi @kambed91 here is another option there probably could work as well

Hi @sovitek Is there a way that i don’t have this first node? “All categories in document”?

that one is mepover and guess archilab have one as well

This will get a list of all categories in the document, as Dynamo categories, sorted alphabetically

import clr

clr.AddReference("RevitNodes")
import Revit

clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

def dynamo_cat(cat):
    return Revit.Elements.Category.ById(cat.Id.Value)

doc = DocumentManager.Instance.CurrentDBDocument

categories = doc.Settings.Categories

OUT = sorted(map(dynamo_cat, categories), key=lambda c: c.Name)

image

2 Likes