Skip to main content

How to export CAD files to DWG?

Export to DWG is available to users of the CAD .NET version 12.1 and higher.

Tip

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.

  1. You can find the compatible sgcadexp.dll version in these folders:
    • ...\CAD .NET 14\bin\DWGExportLib\Win32\
    • ...\CAD .NET 14\bin\DWGExportLib\Win64\
  2. Copy sgcadexp.dll to your project directory where .exe and CADImport.dll are located. Thus, sgcadexp.dll can be loaded at runtime.
  3. Add the using directive with the CADImport and CADImport.Export namespaces.
using CADImport;
using CADImport.Export;
  1. To export a CAD file to DWG, write the SaveCADImageAsDWG function:
    • Declare the CADImage cadImage parameter.
    • Declare the string parameter dwgFilePath that is the file path to the future DWG file.
    • Use the SaveAsDWG method.
public static void SaveCADImageAsDWG(CADImage cadImage, string dwgFilePath)
{
CADtoDWG.SaveAsDWG(cadImage, dwgFilePath);
}
  1. Call the function to export the drawing to DWG.
SaveCADImageAsDWG(vDrawing, "DWGfile.dwg");

You have created the function to export CAD files to DWG.

Note

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");