revit-ifc
revit-ifc copied to clipboard
Fix export linked file using api
This fix is targeting exporting Linked Revit files via Revit Api. not through the UI, The implementation was already set but very coupled to the UI, I separated the export code, and placed it in another IFCLinkDocumentExporter. We may change the name " I don't like long ones"
usage via API is straight forward:
Document doc = uidoc.Document;
View view = uidoc.ActiveGraphicalView;
IFCExportOptions ifcOptions = new IFCExportOptions();
IFCExportConfiguration configExporter= IFCExportConfiguration.CreateDefaultConfiguration();
configExporter.IFCVersion = IFCVersion.IFC2x3;
configExporter.UseActiveViewGeometry = true;
configExporter.UpdateOptions(ifcOptions, view.Id);
configExporter.ExportLinkedFiles = LinkedFileExportAs.ExportSameProject;
doc.Export(@"d:\", "IFC_TestSampleFile", ifcOptions);
// if separated
configExporter.ExportLinkedFiles = LinkedFileExportAs.ExportAsSeparate;
configExporter.LinkExporter.ExportSeparateDocuments(@"d:\IFC_TestSampleFile");
This is tested over Revit 2025 I have also made a workaround sample till this is merged over here