Revit 2022 API - Exporting An NWC File
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to make an app to export an NWC file from Revit using the api, based on certain file names & then publish this into a document management system.
I use the following code to export the nwc, but no model is exported. Does anyone have any example of this or has experienced this issue and knows how to solve it?
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Transaction trans = new Transaction(doc,"Export Models");
trans.Start();
ElementId ExportViewId = doc.ActiveView.Id;
bool isNWCExporterInstalled = OptionalFunctionalityUtils.IsNavisworksExporterAvailable();
if (isNWCExporterInstalled == true)
{
string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
NavisworksExportOptions nwcOptions = new NavisworksExportOptions();
nwcOptions.ViewId = ExportViewId; // Sets the view id to be exported.
nwcOptions.ExportScope = NavisworksExportScope.View;
doc.Export(filePath, "MyModel.nwc", nwcOptions);
}
trans.Commit();
return Result.Succeeded;
Developer Advocacy and Support +