Access to IFCexporter

Hi guys,

Is there a way we can access the IFCexporter (app from Autodesk) so I can automate the process of creating IFC’s?

Right now
I create IFCExportOptions() according to the settings (json) of the IFCexporter
but this revit.doc.Export has a different output compared to creating an ifc through IFCexporter.

Did you ever figure this out?

No, sadly not.

And the regular IFC export is easily accessible but is limited and doesn’t give the correct results.

According to this discussion, it should be possible: https://forums.autodesk.com/t5/revit-api-forum/ifc-export-options/td-p/9686404
But I can’t seem to find how to reference the “IFCExportUI.dll” file.

Probably something along these lines:

import clr
clr.AddReferenceToFileAndPath(r'C:\\ProgramData\\Autodesk\\ApplicationPlugins\\IFC 2024.bundle\\Contents\\2024\\Revit.IFC.Export.dll')
import Revit.IFC.Export as IFCExport

but you first need to install the IFC exporter addin beforehand Releases · Autodesk/revit-ifc · GitHub

Hello Jean_Marc, thank you for your response. In my case (Revit 2023) the exporter addin is installed in this path:

C:\Program Files\Autodesk\Revit 2023\AddIns\IFCExporterUI\Autodesk.IFC.Export.UI.dll

When I try this code:

import clr
clr.AddReferenceToFileAndPath(r'C:\\Program Files\\Autodesk\\Revit 2023\\AddIns\\IFCExporterUI\\Autodesk.IFC.Export.UI.dll')

import Autodesk.IFC.Export.UI as IFCExport
myconfig = IFCExport.BIM.IFC.Export.UI.IFCExportConfiguration.CreateDefaultConfiguration()

I get the error:

ImportError: No module named IFC

Try to dig in from

print(dir(IFCExport))

I don’t know the structure of the code in this specific dll

I think the issue is in the name of the dll. Because when I import Autodesk.IFC.Export.UI it will look in the default Autodesk library (e.g. from Autodesk.Revit.DB import FilteredElementCollector).
When inspecting the dll with dotpeek, you can clearly see the BIM.IFC.Export.UI classes.

import clr
REVITIFCCOMMON = r'C:\ProgramData\Autodesk\ApplicationPlugins\IFC 2023.bundle\Contents\2023\Revit.IFC.Common.dll'
REVITIFCEXPORT = r'C:\ProgramData\Autodesk\ApplicationPlugins\IFC 2023.bundle\Contents\2023\Revit.IFC.Export.dll'
REVITIFCIMPORT = r'C:\ProgramData\Autodesk\ApplicationPlugins\IFC 2023.bundle\Contents\2023\Revit.IFC.Import.dll'
clr.AddReferenceToFileAndPath(REVITIFCCOMMON)
clr.AddReferenceToFileAndPath(REVITIFCEXPORT)
clr.AddReferenceToFileAndPath(REVITIFCIMPORT)
import Revit as BASE

Digging on BASE (showme = dir(BASE)):
[‘IFC’]
[‘Common’, ‘Export’, ‘Import’]
etcetc

As @baaswietse mentions the BIM reference isn’t located in Export.dll.

And I’m still puzzled how the addin is ‘activated’.

I could not figure it out at first…
Hopefully I am stubborn enough:

import clr
clr.AddReferenceToFileAndPath(r'C:\\ProgramData\\Autodesk\\ApplicationPlugins\\IFC 2024.bundle\\Contents\\2024\\IFCExporterUIOverride.dll')
import BIM #access the referenced DLL IFCExporterUIOverride
from pyrevit import script
from pyrevit import DB, revit

doc = revit.doc

output = script.get_output()
output.close_others()

ifc_export_options = DB.IFCExportOptions() # export options for IFC from the Revit default configurator
active_view_id = doc.ActiveView.Id
ifc_export_options.FilterViewId = active_view_id

IFC_exporter_configuration_override = BIM.IFC.Export.UI.IFCExportConfiguration.CreateDefaultConfiguration()
# print(dir(BIM.IFC.Export.UI.IFCExportConfiguration)) # to figure out the members of the class

# just a sample
IFC_exporter_configuration_override.VisibleElementsOfCurrentView = True
IFC_exporter_configuration_override.Export2DElements = True
IFC_exporter_configuration_override.UpdateOptions(ifc_export_options, active_view_id)

with revit.Transaction('Export IFC'):
    doc.Export("C:\\pyRevit", 'test.ifc', ifc_export_options)

Arghh that dll? Seriously. It felt I tested all dll’s in that folder. But how do you figure out you need that dll?

I know…

from this https://forums.autodesk.com/t5/revit-api-forum/ifc-export-options/m-p/12051539/highlight/true#M72221
thanks to Access to IFCexporter - #4 by baaswietse

I’m gonna fiddle with it, hopefully I can grab my own defined settngs now instead of creating them myself using json etc.

Still it puzzles me:

doc.Export("C:\\pyRevit", 'test.ifc', ifc_export_options)

It’s a regular Autodesk default Export command: when does the addin IFCExporter take over?