How to export CAD files to DWG?
Export to DWG is available to users of the CAD .NET version 12.1 and higher.
For more information about the upgrade, please see the topic How to upgrade my CAD .NET version.
CAD .NET supports export to DWG via an additional dynamic link library sgcadexp.dll.
- You can find the compatible
sgcadexp.dllversion in these folders:...\CAD .NET 14\bin\DWGExportLib\Win32\...\CAD .NET 14\bin\DWGExportLib\Win64\
- Copy
sgcadexp.dllto your project directory where.exeandCADImport.dllare located. Thus,sgcadexp.dllcan be loaded at runtime. - Add the
usingdirective with theCADImportandCADImport.Exportnamespaces.
using CADImport;
using CADImport.Export;
- To export a CAD file to DWG, write the
SaveCADImageAsDWGfunction:- Declare the
CADImage cadImageparameter. - Declare the
stringparameterdwgFilePaththat is the file path to the future DWG file. - Use the
SaveAsDWGmethod.
- Declare the
public static void SaveCADImageAsDWG(CADImage cadImage, string dwgFilePath)
{
CADtoDWG.SaveAsDWG(cadImage, dwgFilePath);
}
- Call the function to export the drawing to DWG.
SaveCADImageAsDWG(vDrawing, "DWGfile.dwg");
You have created the function to export CAD files to DWG.
CAD .NET supports export to DWG 2000 and DWG 2004.
The full code listing.
...
using CADImport;
using CADImport.Export;
...
public static void SaveCADImageAsDWG(CADImage cadImage, string dwgFilePath)
{
CADtoDWG.SaveAsDWG(cadImage, dwgFilePath);
}
...
SaveCADImageAsDWG(vDrawing, "DWGfile.dwg");