import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import BuiltInCategory, Category, CategorySet
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# Get all categories in the document
categories = doc.Settings.Categories
# Create a dictionary to store the IFC entities and their corresponding Revit categories
ifc_entities = {}
# Iterate through each category
for category in categories:
if category.AllowsBoundParameters and category.CategoryType == CategoryType.Model:
if category.HasMaterialQuantities:
ifc_entity = category.get_Parameter(BuiltInParameter.IFC_ENTITY_LABEL).AsString()
ifc_entities[ifc_entity] = category.Name
# Print the IFC entities and their corresponding Revit categories
output = {}
for ifc_entity, revit_category in ifc_entities.items():
output.append(f'{ifc_entity}: {revit_category}')
OUT = output
I don’t have time to dig into this today, but it would help if you also provided an IFC model to test in with some of your standard elements and known edge cases (if any).
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
#Preparing input from dynamo to revit
categories = doc.Settings.Categories
catname = []
for c in categories:
catname.append(c.Name)
OUT = catname, categories
need i to import a library to load ? like IfcOpenShell
Just a note that these settings will vary from export to export as the mappings are customizable, so you can’t really rely on one dictionary forever. It’ll be a good base but it isn’t going to be static.