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.dll
version in these folders:...\CAD .NET 14\bin\DWGExportLib\Win32\
...\CAD .NET 14\bin\DWGExportLib\Win64\
- Copy
sgcadexp.dll
to your project directory where.exe
andCADImport.dll
are located. Thus,sgcadexp.dll
can be loaded at runtime. - Add the
using
directive with theCADImport
andCADImport.Export
namespaces.
using CADImport;
using CADImport.Export;
- To export a CAD file to DWG, write the
SaveCADImageAsDWG
function:- Declare the
CADImage cadImage
parameter. - Declare the
string
parameterdwgFilePath
that is the file path to the future DWG file. - Use the
SaveAsDWG
method.
- 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");