Software Companions - Viewing and Conversion Software

Convert Gerber to DXF, PDF, PNG and TIFF using scConverter SDK

Convert multiple Gerber files to a single DXF, PDF or PNG file

scConverter provides several specific functions for converting from Gerber file format to other file formats.
With these functions you can either convert one or more Gerber files to a vector DXF or PDF file, or to an image format like PNG and TIFF.
The following functions are specifically made for Gerber, and Excellon, conversion:

In addition there are two support functions that are used when converting older RS-274D (legacy) Gerber format files:

The following function will make it possible to add Excellon drill files that doesn't contain full format description:

You will find more information about the listed functions in the scConverter documentation.
In this tutorial you will find out how you can use some of these functions to create different types of output.


Convert Gerber files to an image file

Included in the SDK you will find a sample application named scGerberDemo, this application demonstrates how to load Gerber files and then convert these files to different output formats. It will also display the layers with their color and transparency setting. Among the available formats are Adobe PDF, and Gerber files exported to this format will maintain vector geometry and layer information. Here is sample code for loading some Gerber files from our WEB site:

   scconverter.AddGerberLayer("https://www.gerbview.com/demo/project1/LAYER4.gbx", 0x80FF00FF, 0x01);
   scconverter.AddGerberLayer("https://www.gerbview.com/demo/project1/LAYER3.gbx", 0x80FF0000, 0x01);
   scconverter.AddGerberLayer("https://www.gerbview.com/demo/project1/LAYER2.gbx", 0x8000FF00, 0x01);
   scconverter.AddGerberLayer("https://www.gerbview.com/demo/project1/LAYER1.gbx", 0x800000FF, 0x01);
   scconverter.AddGerberLayer("https://www.gerbview.com/demo/project1/CMASK.gbx", 0x80FFFF00, 0x01);
   scconverter.AddGerberLayer("https://www.gerbview.com/demo/project1/SMASK.gbx", 0x8000FFFF, 0x01);
   scconverter.AddGerberLayer("https://www.gerbview.com/demo/project1/SILK.gbx", 0x800000aa, 0x01);

The above code will add each layer with transparency. The color reference is using 0xAABBGGRR format, where AA can be from 0x00 (full transparency) to 0xFF (255 - full opacity). Remember to add the transparency flag (0x01) if you're using transparent color references.
When all the required Gerber files are added you can then convert them to an image. There are two functions that can create image output, one of them to a file and the other can return the image as an IPictureDisp. The returned IPictureDisp value can easily be converted to an Image class object. In the demo application mentioned above you will find code for creating an IPictureDisp, convert to an Image object and then display it in a PictureBox:

   sconverter.BackgroundColor = 0;                   //Use black background
   scconverter.SetMargins(true, 5.0, 5.0, 5.0, 5.0); //Add a 5mm margin around the Gerber data
   stdole.IPictureDisp scPicture = null;
   scconverter.ConvertGerberLayersToImageEx(1.0, 24, 96, 0x01, ref scPicture);
   Image scImage = PictureDispHost.GetPictureFromIPicture(scPicture);
   pictureBox1.Image = scImage;    

The created Image will then look like this in our sample application:


Gerber files loaded and ready for conversion

To create an image output file you can either use the scImage.Save() function with the Image object that was created above, or you can also use the other conversion function named ConvertGerberLayersToImage, as show below:

   double w = 0.0;
   double h = 0.0;
   scconverter.ConvertGerberLayersToImage( "output.png", "PNG", 1.0, 24, 200, 0, ref w, ref h);

This code will create a output PNG file named "output.png" using 24-bit color (true color) and 200 DPI resolution, as shown below:


Gerber files converted to PNG image



Convert one or more Gerber layers to a vector (CAD) file

Instead of converting the Gerber files to an image, you can also use scConverter to create vector formats files like PDF, DXF, SVG and PLT.
If you convert to PDF and SVG formats any set transparency may also be included, you can control if it should be included or not by using the SetConfigValue() function.
For DXF and PDF output each Gerber file will be placed on a separate layer.

   scconverter.PDFWriteFormat = 0;     //Output standard PDF   (editable)
   scconverter.PDFLayers = 1;          //Enable PDF layers
   scconverter.SetConfigValue(17, 0);  //Disable transparent layers for exported PDF
   scconverter.ConvertGerberLayersToCAD( "output.pdf", "PDF");

The picture below show the created PDF in Adobe Acrobat with a separate layer for each added file.


Gerber files converted to PDF with layers displayed

   scconverter.SetConfigValue(17, 1);  //Enable transparent layers for exported PDF
   scconverter.ConvertGerberLayersToCAD( "output.pdf", "PDF");

This code will create a PDF with the transparency set using the AddGerberLayer method as shown below:


Gerber files converted to PDF with layers displayed

Finally we will convert our Gerber files to a SVG file with transparency enabled and display it in Chrome.
Conversion to SVG code:

   scconverter.SetConfigValue(17, 1);  //Enable transparent layers for exported SVG
   scconverter.ConvertGerberLayersToCAD( "output.svg", "SVG");

The resulting SVG file displayed in Chrome:


Gerber files converted to PDF with layers displayed

To create an Autodesk DXF file you only have to replace the format description string as shown here:

   scconverter.ConvertGerberLayersToCAD( "output.dxf", "DXF");



Merging Gerber files into a single file

The above-described functions may be used to merge two or more Gerber files into a single Gerber file.
The following sample code shows how to merge two Gerber layers into a new file:

   scconverter.AddGerberLayer("layer1.gbx", 0x000000, 0);
   scconverter.AddGerberLayer("layer2.gbx", 0x000000, 0);
   scconverter.ConvertGerberLayersToCAD( "merged.gbx", "GERBER");


Merging Excellon files into a single file

With scConverter you can merge several different Excellon drill files into a single Excellon file.
The following sample shows how to to merge two Excellon files into a new file:

   scconverter.AddGerberLayer("drill-pth.drl", 0x000000, 0);
   scconverter.AddGerberLayer("drill-npth.drl", 0x000000, 0);
   scconverter.ConvertGerberLayersToCAD( "drill-merged.drl", "EXCELLON");