Revit secondary development skills (six) --- export DWG file

The author suddenly wanted to use revitAPI to export files in other formats, so he first tested the exported CAD file, which is .dwg. The following methods were found by searching the API:

 

Looking at the above picture, you can know that Document provides a special method, and we can use it directly. When the author uses it, I found that the API also provides a complete method intimately:

This method only needs to provide three parameters to realize the export of CAD files. Readers of the first and second parameters can directly talk about the third parameter. The third parameter is the name of the export setting; as shown in the following figure:

Looking at the picture, you can know that the third parameter is SET 1.0 here; of course, the reader can create a new one or choose another one;

Since the API is directly provided, we can use it directly. The code is as follows:

  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;


           
        }

The above is the way to export CAD files. Of course, there are many further operations, such as adding settings and customizing layer settings. These things require readers to further explore. This article will stop here.

The copyright belongs to the individual. Please indicate the URL: https://blog.csdn.net/fengmochen/article/details/86511508

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/fengmochen/article/details/86511508