Message 1 of 2
Using Navisworks API from within a Revit macro?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to write a Revit 2016 macro that exports a nwc file and then convert it into a 2015 nwd using the Navisworks API from within the same macro.
Is this possible?
I managed to use the Automation tools to simply save a 2016 nwd as follows
/* * Created by SharpDevelop. * User: Sam * Date: 2/8/2016 * Time: 7:09 PM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using Autodesk.Revit.UI; using Autodesk.Revit.DB; using Autodesk.Revit.UI.Selection; using System.Collections.Generic; using System.Linq; using System.IO; using Autodesk.Navisworks.Api.Automation; using Autodesk.Navisworks.Api; using ReviewConverter; namespace MyTools { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] [Autodesk.Revit.DB.Macros.AddInId("0450DEA7-E6A9-405F-AA51-28D7E8B7967E")] public partial class ThisApplication { private void Module_Startup(object sender, EventArgs e) { } private void Module_Shutdown(object sender, EventArgs e) { } #region Revit Macros generated code private void InternalStartup() { this.Startup += new System.EventHandler(Module_Startup); this.Shutdown += new System.EventHandler(Module_Shutdown); } #endregion public void ExportNWC() { UIDocument uidoc = this.ActiveUIDocument; Autodesk.Revit.DB.Document doc = uidoc.Document; NavisworksExportOptions opt = new NavisworksExportOptions(); opt.ConvertElementProperties = true; opt.ExportLinks=true; opt.ExportRoomAsAttribute=false; opt.ExportRoomGeometry=false; opt.ExportScope= NavisworksExportScope.View; opt.FindMissingMaterials=false; opt.ViewId=uidoc.ActiveView.Id; doc.Export("C://nwcExportTest/","test", opt); FileInfo f = new FileInfo("C://nwcExportTest/test.nwc"); Autodesk.Navisworks.Api.Automation.NavisworksApplication navApp = new NavisworksApplication(); navApp.Visible=true; navApp.DisableProgress(); navApp.OpenFile(f.FullName); navApp.SaveFile(f.FullName.TrimEnd(Char.Parse("c"))+"d"); navApp.EnableProgress(); } } }
But the Automation.Navisworksapplication.saveFile() method does not have an overload for saving back to 2015, I see this available in the Autodesk.Navisworks.Api.Application.ActiveDocument.SaveFile() method, but I'm not sure how to use that from within the Revit macro.
Any suggestions?
Thanks,
Sam