Revit二次开发之技能篇(六)———导出DWG文件

作者突然想试一下用revitAPI导出其他格式的文件,于是先测试了一下导出CAD文件也就是.dwg。通过查找API找到了以下方法:

查看上图可以知道,Document提供了专门的方法,我们直接使用就可以了,在作者使用的时候发现API还贴心地提供了完整的方法:

这个方法只需要提供三个参数就可以实现CAD文件的导出,第一二个参数读者都会,直接说第三个参数,第三个参数是导出设置的名称;如下图:

看图可以知道第三个参数就是这里的SET 1.0;当然了读者可以自己重新新建一个或者选择其他的;

既然API直接提供了,我们直接拿来用就可以了,代码如下:

  public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
           UIApplication uiApp= commandData.Application;
            UIDocument uiDocument = uiApp.ActiveUIDocument;
            Document doc = uiDocument.Document;
            Document linkDoc = FileOperation.GetLinkFile(uiApp,doc);
            //自定义导图设置;
            string setName = "SET 1.0";
            bool isSuccess = false;
            isSuccess = ExportDWG(doc, doc.ActiveView, setName);
            if (isSuccess)
            {
                return Result.Succeeded;
            }
            else return Result.Failed;


           
        }

以上就是导出CAD文件的方式,当然了也还有很多进一步的操作例如,增加设置,自定义图层设置,这些东西需要读者进一步去探索,这篇文章就到这里。

版权归个人所有转载请注明网址:https://blog.csdn.net/fengmochen/article/details/86511508

猜你喜欢

转载自blog.csdn.net/fengmochen/article/details/86511508