Introduction to Gerber X2
Gerber X2 is an extension of the standard Gerber format used for printed circuit board (PCB) fabrication data. It adds new features and capabilities to enhance the manufacturing process. Gerber X2 was developed by Ucamco, the company that maintains the Gerber format standard.
The original Extended Gerber format, also known as RS-274X, has been the de facto standard for PCB Fabrication data exchange since the 1980s. While robust and reliable, it had some limitations. Gerber X2 builds upon Extended Gerber to provide additional data and address some shortcomings.
Key Features of Gerber X2
The main enhancements in Gerber X2 include:
- Attributes to convey intent and function of features
- Nested step and repeat for more efficient data transfer
- Hierarchical organization of the layer structure
- Improved support for positive and negative image polarity
- Metadata to specify the CAD application and version
These additions aim to improve fabrication quality, reduce errors, and streamline communication between designers and manufacturers. Let’s explore each of these features in more depth.
Attributes in Gerber X2
One of the most significant changes in Gerber X2 is the introduction of attributes. Attributes allow designers to specify the intent or function of a feature directly in the Gerber file. This reduces ambiguity and provides extra information to the manufacturer.
Attribute Syntax
Attributes in Gerber X2 use the following syntax:
%TA.AperFunction,<function>*%
Where <function>
is replaced by a standardized string indicating the purpose of the aperture. Some common attribute values include:
Attribute | Description |
---|---|
Conductor |
Area that carries current |
NonConductor |
Area that does not carry current |
ComponentPad |
Pad for component interconnect |
ViaPad |
Pad for layer interconnect |
CutOut |
Board outline or hole |
Attributes are associated with D-codes and apply to all features that reference that aperture. Multiple attributes can be specified for a single D-code.
Benefits of Attributes
Explicitly labeling the function of features with attributes has several benefits for the PCB fabrication process:
- Reduces the risk of misinterpreting the designer’s intent
- Allows more automated checks and validations by CAM software
- Provides better control over impedance and signal integrity
- Enables more intelligent panelization and optimized layup
By conveying richer information, Gerber X2 attributes contribute to higher quality manufacturing with fewer errors and less back-and-forth between design and production.
Nested Step and Repeat
Gerber X2 introduces a new command for defining step and repeat operations in a nested fashion. This allows more compact representation of repetitive patterns and can significantly reduce file sizes.
Legacy Step and Repeat
In Extended Gerber, the step and repeat command has the following syntax:
%SRX<Nx>Y<Ny>I<dx>J<dy>*%
Where:
– Nx
and Ny
specify the number of columns and rows
– dx
and dy
specify the X and Y distance between columns and rows
This command replicates the entire Gerber file content by the specified number of times at fixed offsets. It is limited to a single level of repetition.
Nested Step and Repeat in Gerber X2
Gerber X2 introduces a new SR command that allows defining step and repeat operations in a nested manner:
%SRX<Nx>Y<Ny>I<dx>J<dy>*%
<Gerber_content>
%SR*%
The opening %SR...
command marks the start of step and repeat content, while the closing %SR*%
indicates the end. The Gerber content enclosed between these delimiters is replicated based on the specified pattern.
Critically, Gerber X2 allows nesting step and repeat blocks to compactly represent hierarchical repetition. Here’s an example:
%SRX4Y4I5.0J5.0*%
%SRX2Y2I2.0J2.0*%
<Gerber_content>
%SR*%
%SR*%
In this case, the inner step and repeat block is replicated 2×2 times, and that entire set of features is then replicated 4×4 times by the outer block. The effective result is 8×8 copies of the original content.
Advantages of Nested Step and Repeat
The nested step and repeat capability in Gerber X2 offers several benefits:
- More efficient representation of complex repetitive patterns
- Smaller file sizes for Gerber data with multiple levels of hierarchy
- Easier for designers to specify the intent of stepped content
- Reduces the risk of errors in handling duplicate features
By leveraging nested step and repeat, both design and manufacturing can work with clearer and more concise data.

Hierarchical Layer Structure
Gerber X2 introduces a formal hierarchical layer structure to better organize and represent the layered construction of a PCB. This hierarchy uses a file naming convention and attributes to express the relationships between layers.
Legacy Layer Representation
In Extended Gerber, each layer in a PCB design is typically saved as a separate file. The file naming is ad hoc and relies on conventions to identify the layer function, like:
top.gbr
for top copper layerbottom.gbr
for bottom copper layersolder_mask_top.gbr
for top solder mask layer
While this works, it lacks a formal specification and can be error-prone, especially for complex stackups with many layers.
Hierarchical Layers in Gerber X2
Gerber X2 introduces a standard file naming scheme and layer types to represent the hierarchy:
<layer_function>.<layer_number>.<format>
Where:
– <layer_function>
is a standard prefix identifying the layer purpose
– <layer_number>
is an optional number for inner layers
– <format>
is the file extension, typically .gbr
Some common layer function prefixes include:
Prefix | Layer Type |
---|---|
tcu |
Top copper |
bcu |
Bottom copper |
icu |
Inner copper |
tsm |
Top solder mask |
bsm |
Bottom solder mask |
tss |
Top silkscreen |
bss |
Bottom silkscreen |
out |
Board outline |
For example, a 4-layer PCB might have the following Gerber X2 files:
tcu.gbr
– Top coppericu1.gbr
– Inner copper 1icu2.gbr
– Inner copper 2bcu.gbr
– Bottom coppertsm.gbr
– Top solder maskbsm.gbr
– Bottom solder masktss.gbr
– Top silkscreenbss.gbr
– Bottom silkscreenout.gbr
– Board outline
In addition to the file naming, Gerber X2 uses the FileFunction
and FilePolarity
attributes to specify the role and polarity of each layer file. For example:
%TF.FileFunction,Copper,L1,Top*%
%TF.FilePolarity,Positive*%
This clearly identifies the file’s purpose in the fabrication data set.
Benefits of Hierarchical Layers
Using a formal hierarchical layer structure in Gerber X2 has several advantages:
- Clearly conveys the layered structure of the PCB
- Reduces the risk of errors or misinterpretation
- Allows for more automated processing and validation
- Provides a standard way to identify layer types and functions
By bringing more organization and clarity to the layer stackup, Gerber X2’s hierarchical structure enhances the overall fabrication process.
Improved Image Polarity Handling
Gerber X2 introduces explicit commands for specifying the image polarity of objects. This provides a clearer and more robust way to handle negative and positive image data.
Polarity in Extended Gerber
In Extended Gerber, image polarity is typically handled by the %LPD*%
(dark polarity) and %LPC*%
(clear polarity) commands. Dark polarity indicates that objects are “painted” onto the background, while clear polarity means that objects are “erased” from a filled background.
However, the behavior of these commands can be ambiguous, especially when used with apertures that have complex shapes or holes.
Image Polarity in Gerber X2
Gerber X2 introduces new LP
commands to explicitly control the image polarity of objects:
%LPD*% ; Set dark polarity (default)
%LPC*% ; Set clear polarity
%LPT*% ; Flip polarity for subsequent objects
The %LPD*%
and %LPC*%
commands set the polarity mode for all subsequent objects, while %LPT*%
toggles the polarity on a per-object basis.
Crucially, Gerber X2 also introduces the %LPD*%
and %LPC*%
commands to set the polarity of contours within an aperture definition:
%ADD100*%
%LPD*%
G36*
X0Y0D02*
X1000000Y0D01*
X1000000Y1000000D01*
X0Y1000000D01*
X0Y0D01*
G37*
%LPC*%
G36*
X250000Y250000D02*
X750000Y250000D01*
X750000Y750000D01*
X250000Y750000D01*
X250000Y250000D01*
G37*
In this example, the aperture consists of a dark polarity square with a clear polarity square hole in the center. The explicit contour polarity commands make the intent clear.
Advantages of Improved Polarity Handling
The improved image polarity handling in Gerber X2 offers several benefits:
- Eliminates ambiguity in handling negative features
- Allows for more complex and precise aperture shapes
- Reduces the risk of misinterpretation between design and manufacturing
- Enables more automated validation and processing of image data
By providing explicit control over image polarity, Gerber X2 enhances the accuracy and reliability of the PCB fabrication process.
Embedded Metadata
Gerber X2 allows including metadata directly in Gerber files to convey additional context about the design data. This metadata identifies the CAD application and provides design information.
Metadata Commands
Metadata in Gerber X2 is specified using two new commands:
%TF.GenerationSoftware,<vendor>,<application>,<version>*%
%TF.CreationDate,<YYYY-MM-DD>*%
The GenerationSoftware
command identifies the CAD tools used to create the Gerber files, while the CreationDate
specifies when the files were generated.
Example Metadata
Here’s an example of embedding metadata in a Gerber X2 file:
%TF.GenerationSoftware,Ucamco,UcamX,2017.12*%
%TF.CreationDate,2018-01-20*%
This indicates that the file was generated by Ucamco’s UcamX software version 2017.12 on January 20th, 2018.
Benefits of Metadata
Including metadata in Gerber X2 files provides several advantages:
- Identifies the source CAD application for the fabrication data
- Provides a timestamp to track version history
- Enables more automated processing and tracking of design files
- Improves communication between design and manufacturing teams
By embedding key context directly in the Gerber data, X2 metadata helps streamline the overall workflow from design to production.
FAQ
What is the difference between Gerber X2 and Extended Gerber?
Gerber X2 is an extension to the legacy Extended Gerber format (RS-274X). It adds several new features and capabilities, such as attributes, nested step and repeat, hierarchical layer structure, improved image polarity handling, and embedded metadata. X2 is fully backwards compatible with Extended Gerber.
Do I need special CAD software to generate Gerber X2 files?
Most modern PCB CAD tools support exporting Gerber X2 data. However, you may need to explicitly enable the X2 mode in your output settings. Check your CAD application documentation for specific instructions on generating X2 files.
Can Gerber X2 files be used with older PCB fabrication equipment?
Yes, Gerber X2 is designed to be backwards compatible with legacy Extended Gerber (RS-274X) equipment and software. The new commands and syntax in X2 will be ignored by older systems, while the core Gerber data remains usable.
Are there any disadvantages to using Gerber X2?
The main disadvantage of Gerber X2 is that it may not be supported by some older CAD tools or fabrication software. Transitioning to X2 may require updating your toolchain. Additionally, X2 files may be slightly larger than legacy Gerber due to the extra metadata and attributes.
How widely adopted is Gerber X2 in the industry?
Gerber X2 has seen growing adoption since its introduction in 2014. Many leading CAD vendors and PCB Manufacturers have embraced the format. However, legacy Extended Gerber remains in widespread use as well. The transition to X2 is an ongoing process in the industry.
Conclusion
Gerber X2 represents a significant step forward for the PCB fabrication data format. By introducing new capabilities like attributes, nested step and repeat, hierarchical layers, improved polarity handling, and metadata, X2 enables more precise, efficient, and automated data exchange between PCB design and manufacturing.
While adoption of X2 is an ongoing process, the benefits are clear. X2 helps reduce errors and ambiguity, streamline communication, and ultimately lead to higher quality PCB products.
As the industry continues to move towards more intelligent and automated workflows, Gerber X2 is well positioned to serve as the data backbone for next-generation electronics manufacturing.
Leave a Reply