Skip to content

options

The options module contains definition of Options class.

Options

Bases: BaseModel

The Options class aggregates configuration options for the Gerber formatter.

For detailed description of individual options, please visit (TODO: Add doc link).

indent_character class-attribute instance-attribute

indent_character: Literal[' ', '\t'] = Field(default=' ')

Character used for indentation, by default " " (space).

macro_body_indent class-attribute instance-attribute

macro_body_indent: Union[str, int] = Field(default=0)

Indentation of macro body, could be either a string containing desired whitespaces or integer which will be used to create indent string based on indent_character, by default 0 which results in no indentation.

macro_param_indent class-attribute instance-attribute

macro_param_indent: Union[str, int] = Field(default=0)

Indentation of macro parameters, could be either a string containing desired whitespaces or integer which will be used to create indent string based on indent_character, by default 0 which results in no indentation.

macro_param_indent indentation is added on top of macro body indentation.

macro_param_indent has effect only when macro_split_mode is PARAMETERS.

macro_split_mode class-attribute instance-attribute

macro_split_mode: MacroSplitMode = Field(
    default=SplitOnPrimitives
)

Changes how macro definitions are formatted, by default MacroSplitMode.SplitOnPrimitives.


When NoSplit is selected, macro definition will be formatted as a single line.

%AMDonut*1,1,$1,$2,$3*$4=$1x0.75*1,0,$4,$2,$3*%

When SplitOnPrimitives is selected, macro definition will be formatted with each primitive in a new line.

%AMDonut*
1,1,$1,$2,$3*
$4=$1x0.75*
1,0,$4,$2,$3*%

When SplitOnParameters is selected, macro definition will be formatted with each primitive on a new line and each parameter of a primitive on a new line.

%AMDonut*
1,
1,
$1,
$2,
$3*
$4=$1x0.75*
1,
0,
$4,
$2,
$3*%

Use macro_body_indent and macro_param_indent to control indentation.

macro_end_in_new_line class-attribute instance-attribute

macro_end_in_new_line: MacroEndInNewLine = Field(default=No)

Toggles placing % sign which marks the end of macro in new line, by default MacroEndInNewLine.No

block_aperture_body_indent class-attribute instance-attribute

block_aperture_body_indent: Union[str, int] = Field(
    default=0
)

Indentation of block aperture definition body, could be either a string containing desired whitespaces or integer which will be used to create indent string based indent_character, by default 0 which results in no indentation.

This indentations stacks for nested block apertures.

step_and_repeat_body_indent class-attribute instance-attribute

step_and_repeat_body_indent: Union[str, int] = Field(
    default=0
)

Indentation of step and repeat definition body, could be either a string containing desired whitespaces or integer which will be used to create indent string based indent_character, by default 0 which results in no indentation.

This indentations stacks for nested step and repeat blocks.

float_decimal_places class-attribute instance-attribute

float_decimal_places: int = Field(default=-1)

Limit number of decimal places shown for float values, by default -1 which means as many decimal places as needed.

float_trim_trailing_zeros class-attribute instance-attribute

float_trim_trailing_zeros: FloatTrimTrailingZeros = Field(
    default=Yes
)

Remove trailing zeros from floats, by default FloatTrimTrailingZeros.Yes.

When this is set to FloatTrimTrailingZeros.Yes, after floating point number is formatted with respect to float_decimal_places, trailing zeros are removed. If all zeros after decimal point are removed, decimal point is also removed.

d01_indent class-attribute instance-attribute

d01_indent: Union[str, int] = Field(default=0)

Custom indentation of D01 command, could be either a string containing desired whitespaces or integer which will be used to create indent string based indent_character, by default 0

d02_indent class-attribute instance-attribute

d02_indent: Union[str, int] = Field(default=0)

Custom indentation of D02 command, could be either a string containing desired whitespaces or integer which will be used to create indent string based indent_character, by default 0

d03_indent class-attribute instance-attribute

d03_indent: Union[str, int] = Field(default=0)

Custom indentation of D03 command, could be either a string containing desired whitespaces or integer which will be used to create indent string based indent_character, by default 0

line_end class-attribute instance-attribute

line_end: Literal['\n', '\r\n'] = Field(default='\n')

Line ending character, Unix or Windows style, by default " " (Unix style) If strip_whitespace is enabled, this setting is ignored and no line endings are added.

empty_line_before_polarity_switch class-attribute instance-attribute

empty_line_before_polarity_switch: (
    EmptyLineBeforePolaritySwitch
) = Field(default=No)

Add empty line before polarity switch, by default EmptyLineBeforePolaritySwitch.Yes

Inserting empty lines before polarity switches enhances visual separation of sequences of commands with different polarities.

keep_non_standalone_codes class-attribute instance-attribute

keep_non_standalone_codes: KeepNonStandaloneCodes = Field(
    default=Keep
)

Keep non-standalone codes in the output, by default KeepNonStandaloneCodes.Keep

If this option is disabled, legacy merged code forms like G70D02* will be divided into two separate commands, G70* and D02*, otherwise they will be kept as is.

remove_g54 class-attribute instance-attribute

remove_g54: RemoveG54 = Field(default=Keep)

Remove G54 code from output, by default RemoveG54.Keep

G54 code has no effect on the output, it was used in legacy files to prefix select aperture command.

remove_g55 class-attribute instance-attribute

remove_g55: RemoveG55 = Field(default=Keep)

Remove G55 code from output, by default RemoveG55.Keep

G55 code has no effect on the output, it was used in legacy files to prefix flash command.

explicit_parenthesis class-attribute instance-attribute

explicit_parenthesis: ExplicitParenthesis = Field(
    default=KeepOriginal
)

Toggle explicit parenthesis around all mathematical expressions within macro, by default ExplicitParenthesis.KeepOriginal

strip_whitespace class-attribute instance-attribute

strip_whitespace: StripWhitespace = Field(default=Default)

Toggle stripping of whitespace from the output, by default StripWhitespace.Default which results in normal whitespace handling.