Expand description
§Gerber commands
This crate implements the basic building blocks of Gerber (RS-274X, aka Extended Gerber version 2) code. It focusses on the low level types and does not do any semantic checking.
For example, you can use an aperture without defining it. This will generate syntactically valid but semantially invalid Gerber code, but this module won’t complain.
§Traits: GerberCode and PartialGerberCode
There are two main traits that are used for code generation:
GerberCode
generates a full Gerber code line, terminated with a newline character.PartialGerberCode
(internal only) generates Gerber representation of a value, but does not represent a full line of code.
Structs§
- Aperture
Definition - Aperture
Macro - Center
Line Primitive - Circle
- Circle
Primitive - Coordinate
Format - The coordinate format specifies the number of integer and decimal places in
a coordinate number. For example, the
24
format specifies 2 integer and 4 decimal places. The number of decimal places must be 4, 5 or 6. The number of integer places must be not more than 6. Thus the longest representable coordinate number isnnnnnn.nnnnnn
. - Coordinate
Number - Coordinate numbers are integers conforming to the rules set by the FS command.
- Coordinate
Offset - Coordinate offsets can be used for interpolate operations in circular interpolation mode.
- Coordinates
- Coordinates are part of an operation.
- Generation
Software - Image
Name - Gerber spec 2024.05 8.1.9 “Scale Factor (SF)” By default, A=X, B=Y, but this changes depending on the axis select command (AS)
- Image
Offset - Gerber spec 2024.05 8.1.8 “Offset (OF)” By default, A=X, B=Y, but this changes depending on the axis select command (AS)
- Image
Scaling - Gerber spec 2024.05 8.1.9 “Scale Factor (SF)” By default, A=X, B=Y, but this changes depending on the axis select command (AS)
- Moire
Primitive - The moiré primitive is a cross hair centered on concentric rings (annuli). Exposure is always on.
- Outline
Primitive - Pin
- Polygon
- Polygon
Primitive - A polygon primitive is a regular polygon defined by the number of vertices, the center point and the diameter of the circumscribed circle.
- Rectangular
- Rotation
- Scaling
- Supplier
Part - Thermal
Primitive - The thermal primitive is a ring (annulus) interrupted by four gaps. Exposure is always on.
- Uuid
- A Universally Unique Identifier (UUID).
- Variable
Definition - Vector
Line Primitive
Enums§
- Aperture
- Aperture
Attribute - Aperture
Block - Aperture
Function - ApertureFunction
- Axis
Select - Command
- Comment
Content - See Gerber spec 2024.05.
- Component
Characteristics - ComponentCharacteristics 2024.05 - 5.6.1.6 “Cxxx (Component Characteristics)”
- Component
Drill - 2024.05 spec mismatch warning: Aperture function “.AperFunction.ComponentDill” has “PressFit” (uppercase F) whereas Component Characteristics “.CMnt” has “Pressfit” (lowercase f)“
- Component
Mounting - 2024.05 spec mismatch warning: Aperture function “.AperFunction.ComponentDill” has “PressFit” (uppercase F) whereas Component Characteristics “.CMnt” has “Pressfit” (lowercase f)“
- Component
Outline - Copper
Type - DCode
- Drill
Function - Drill
Route Type - Extended
Code - Extended
Position - Fiducial
Scope - File
Attribute - File
Function - File
Polarity - Function
Code - GCode
- Gerber
Error - IPC4761
ViaProtection - Ident
- Image
Mirroring - Gerber spec 2024.05 8.1.7 “Mirror Image (MI)”
- Image
Polarity - Image
Rotation - Gerber spec 2024.05 8.1.5 “Image Rotation (IR)”
- Interpolation
Mode - MCode
- Macro
Boolean - The gerber specification (2021.02 - 2024.05) 3.4 Data Types does not define a boolean However, there are various places where they are used in macros whey there are defined as having a 0 or 1 value. Such as the ‘exposure’ flag.
- Macro
Content - Gerber specification (2021.02 - 2024.05) 4.5.1.1 Primitives / Overview “Except for the comment all the parameters can be a decimal, integer, macro variables or an arithmetic expression”
- Macro
Decimal - A macro decimal can either be an f64 or a variable placeholder.
- Macro
Integer - Gerber specification (2021.02 - 2024.05) 3.4.1 Integers “Integers must fit in a 32-bit signed integer”
- Mirroring
- Net
- NonPlated
Drill - Object
Attribute - Operation
- Part
- Plated
Drill - Polarity
- Position
- Profile
- Quadrant
Mode - SmdPad
Type - Standard
Comment - See Gerber spec 2024.05.
- Step
AndRepeat - Text
Mirroring - Text
Mode - Unit
Traits§
- Gerber
Code - All types that implement this trait can be converted to a complete Gerber Code line. Generated code should end with a newline.
- Into
Optional Coordinate