您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章主要介绍“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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。