Hi,
probably is too simple, but I can’t find a solution unitl now.
I need a list of all categories inside of revit, basically this list:
How can I get it?!
Thank you everyone
The list will vary by release, and contains a lot of stuff which isn’t really suitable for human consumption so to speak. As such we need more context on the ask.
Do you want the categories, or the names? If names, what language do you want them in?
Give the following code a try, it should give you a initial bit of info
#Created By Brendan Cassidy
import clr
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
categoryList = doc.Settings.Categories
OUT=[]
for cat in categoryList:
if cat.AllowsBoundParameters and not cat.IsTagCategory and cat.CategoryType == CategoryType.Model:
OUT.append([cat.Name,cat])
OUT.sort()
But why do you need them?
Nothing beyond what you’ve posted above can really be provided without more insight into what you’re after. My guess is you’ll want to get the categories from the document, filter out non-built in categories, and then pull the category type, and perhaps more from there. Since your task is specific you’ll likely need to write this in Python on your own. Towards that end this will help: Making a Category names, BuiltInCategory and category Object dictinary
Did you try this? List of categories of revit - #4 by Brendan_Cassidy
Or this? Making a Category names, BuiltInCategory and category Object dictinary
If so, what about them didn’t work? Are you trying to return the categories in Dynamo?
Try the following code and do look at this image
#Created By Brendan Cassidy
import clr
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
categoryList = doc.Settings.Categories
OUT=[]
for cat in categoryList:
if cat.AllowsBoundParameters and not cat.IsTagCategory and cat.CategoryType == CategoryType.Model:
OUT.append([cat.Name,Revit.Elements.Category.ById(cat.Id.IntegerValue)])
OUT.sort()
Wise to use my updated code as it converts the category to a dynamo object for use in out of the box dynamo nodes.
Have a relook at my image i posted, this should give you enough info to by pass your error.
EG use whats in my image and use either list out of the code block depending on what you need.
If you want to use the categories to get all elements then you use the list of that(red circled output), but if you want to use the string name then use the other list(Blue circled output).