Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66666

Re: Batch process export from Revit to Navisworks

$
0
0

Here is code example you can refine and run, FYI:

 

 public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Application revitApp = commandData.Application.Application;
string [] files = Directory.GetFiles(@"<your folder contains rvt files>", "*.rvt", SearchOption.TopDirectoryOnly);
foreach (var file in files)
{
// open each rvt
Document rvtDoc = revitApp.OpenDocumentFile(file);
//
// find one 3d view
FilteredElementCollector coll = new FilteredElementCollector(rvtDoc);
View3D v3d = coll.OfClass(typeof(View3D)).ToElements().Cast<View3D>().Where(v => !v.IsTemplate).First();
//
// create export options, you may need to specify more options
NavisworksExportOptions opt = new NavisworksExportOptions();
opt.ExportScope = NavisworksExportScope.View;
opt.ViewId = v3d.Id;
//
// export the 3d view model to nwc
rvtDoc.Export(@"<your export folder>", rvtDoc.Title + ".nwc", opt);
rvtDoc.Close(false);
}
return Result.Succeeded;


Viewing all articles
Browse latest Browse all 66666

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>