revit-ifc icon indicating copy to clipboard operation
revit-ifc copied to clipboard

Fix export linked file using api

Open mostafa901 opened this issue 8 months ago • 2 comments

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

mostafa901 avatar Jun 14 '24 20:06 mostafa901