您好,登錄后才能下訂單哦!
這篇文章主要介紹“Revit怎么導出其他文件格式”,在日常操作中,相信很多人在Revit怎么導出其他文件格式問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Revit怎么導出其他文件格式”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
Revit 可以導出多種其他文件格式,比如:DWG,DWF,IFC,NWC等等,主要通過API:doc.Export()方法.
實例代碼:
public class ExportToOtherCommand : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; string projectName = Path.GetFileNameWithoutExtension(doc.PathName); string viewName = doc.ActiveView.Name; ////導出Dwf //using (Transaction trans = new Transaction(doc, "Export to Dwf file")) //{ // trans.Start(); // ExportToDWF(doc, $"D:\\Shared\\{projectName}_{viewName}.dwf"); // trans.Commit(); //} ////導出Nwc //ExportToNwc(doc, $"D:\\Shared\\{projectName}_{viewName}.nwc"); ExportToDwg(doc, $"D:\\Shared\\{projectName}_{viewName}.dwg",false); return Result.Succeeded; } /// <summary> /// 導出Nwc文件,不需要開啟事務 /// </summary> /// <param name="document"></param> /// <param name="pathFullName"></param> public void ExportToNwc(Document document, string pathFullName) { NavisworksExportOptions nweOptions = new NavisworksExportOptions(); nweOptions.ExportScope = NavisworksExportScope.Model; nweOptions.ViewId = document.ActiveView.Id; //導出是否包括鏈接模型 nweOptions.ExportLinks = true; //判斷是否安裝了Navisworks bool isExporterAvailable = OptionalFunctionalityUtils.IsNavisworksExporterAvailable(); if (isExporterAvailable) { string folder = Path.GetDirectoryName(pathFullName); string name = Path.GetFileNameWithoutExtension(pathFullName); document.Export(folder, name, nweOptions); } else { TaskDialog.Show("tip", "導出失敗!沒有安裝Navisworks"); } } /// <summary> /// 導出dwf , 導出需要開啟事務 /// </summary> /// <param name="document"></param> /// <param name="pathFullName"></param> /// <param name="isActiveView"></param> public void ExportToDWF(Document document, string pathFullName, bool isActiveView = true) { FilteredElementCollector collector = new FilteredElementCollector(document); collector.OfClass(typeof(View)).OfCategory(BuiltInCategory.OST_Views); DWFExportOptions dwfOptions = new DWFExportOptions { CropBoxVisible = true, ExportingAreas = true, ExportTexture = false }; ViewSet views = new ViewSet(); if (isActiveView) { views.Insert(document.ActiveView); } else { //多個視圖 foreach (View view in collector.ToElements()) { if (view.CanBePrinted) { views.Insert(view); } } } string folder = Path.GetDirectoryName(pathFullName); string name = Path.GetFileNameWithoutExtension(pathFullName); document.Export(folder,name, views, dwfOptions); } public void ExportToDwg(Document document, string pathFullName, bool isActiveView = true) { FilteredElementCollector collector = new FilteredElementCollector(document); collector.OfClass(typeof(View)).OfCategory(BuiltInCategory.OST_Views); DWGExportOptions dwgOptions = new DWGExportOptions { FileVersion = ACADVersion.R2010, }; string folder = Path.GetDirectoryName(pathFullName); string name = Path.GetFileNameWithoutExtension(pathFullName); List<ElementId> viewIds = new List<ElementId>(); if (isActiveView) { viewIds.Add(document.ActiveView.Id); } else { //多個視圖 foreach (View view in collector.ToElements()) { if (view.CanBePrinted) { viewIds.Add(view.Id); } } } document.Export(folder, name, viewIds, dwgOptions); } }
到此,關于“Revit怎么導出其他文件格式”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。