diff --git a/docs/source/configuration/sup_globals.rst b/docs/source/configuration/sup_globals.rst index bfa7582c..96ec3a05 100644 --- a/docs/source/configuration/sup_globals.rst +++ b/docs/source/configuration/sup_globals.rst @@ -195,8 +195,8 @@ - ``time_format`` :index:`: ` [string='%H-%M-%S'] Format used for the time we started the script. Uses the `strftime` format. - ``time_reformat`` :index:`: ` [boolean=true] Tries to reformat the PCB/SCH date using the `date_format`. This assumes you let KiCad fill this value and hence the time is in ISO format (YY-MM-DD). - - ``units`` :index:`: ` [string=''] [millimeters,inches,mils] Default units. Affects `position`, `bom` and `panelize` outputs. - Also KiCad 6 dimensions. + - ``units`` :index:`: ` [string=''] [millimeters,inches,mils] Default units. Affects `position`, `bom` and `panelize` outputs and + the `erc` and `drc` preflights. Also KiCad 6 dimensions. - ``use_dir_for_preflights`` :index:`: ` [boolean=true] Use the global `dir` as subdir for the preflights. - ``use_os_env_for_expand`` :index:`: ` [boolean=true] In addition to KiCad text variables also use the OS environment variables when expanding `${VARIABLE}`. - ``variant`` :index:`: ` [string=''] Default variant to apply to all outputs. diff --git a/docs/source/configuration/sup_preflights.rst b/docs/source/configuration/sup_preflights.rst index e056107b..bf1b054a 100644 --- a/docs/source/configuration/sup_preflights.rst +++ b/docs/source/configuration/sup_preflights.rst @@ -58,6 +58,7 @@ Supported preflights - ``format`` :index:`: ` [string|list(string)='HTML'][RPT,HTML,CSV,JSON] Format/s used for the report. You can specify multiple formats. + - ``units`` :index:`: ` [string='millimeters'] [millimeters,inches,mils] Units used for the positions. Affected by global options. - ``warnings_as_errors`` :index:`: ` [boolean=false] ERC warnings are considered errors, they still reported as errors, but consider it an error. - **erc_warnings**: :index:`: ` [boolean=false] **Deprecated**, use the `warnings_as_errors` option from `run_erc`. diff --git a/kibot/globals.py b/kibot/globals.py index 7d17c1ec..41d88a86 100644 --- a/kibot/globals.py +++ b/kibot/globals.py @@ -272,8 +272,8 @@ def __init__(self): """ Tries to reformat the PCB/SCH date using the `date_format`. This assumes you let KiCad fill this value and hence the time is in ISO format (YY-MM-DD) """ self.units = '' - """ [millimeters,inches,mils] Default units. Affects `position`, `bom` and `panelize` outputs. - Also KiCad 6 dimensions """ + """ [millimeters,inches,mils] Default units. Affects `position`, `bom` and `panelize` outputs and + the `erc` and `drc` preflights. Also KiCad 6 dimensions """ self.use_dir_for_preflights = True """ Use the global `dir` as subdir for the preflights """ self.variant = '' diff --git a/kibot/pre_erc.py b/kibot/pre_erc.py index c787fb87..7c85433d 100644 --- a/kibot/pre_erc.py +++ b/kibot/pre_erc.py @@ -20,6 +20,7 @@ GENERATOR_CSS, W_ERC, W_FILXRC) from .log import get_logger logger = get_logger(__name__) +UNITS_2_KICAD = {'millimeters': 'mm', 'inches': 'in', 'mils': 'mils'} def warning(msg): @@ -59,6 +60,8 @@ def __init__(self): """ ERC warnings are considered errors, they still reported as errors, but consider it an error """ self.dont_stop = False """ Continue even if we detect ERC errors """ + self.units = 'millimeters' + """ [millimeters,inches,mils] Units used for the positions. Affected by global options """ super().__init__() self.filters = FilterOptionsXRC self.set_doc('filters', " [list(dict)] Used to manipulate the ERC violations. Avoid using the *filters* preflight") @@ -373,7 +376,8 @@ def run(self): output = outputs[0] os.makedirs(os.path.dirname(output), exist_ok=True) # Run the ERC from the CLI - cmd = ['kicad-cli', 'sch', 'erc', '-o', output, '--format', 'json', '--severity-all', GS.sch_file] + cmd = ['kicad-cli', 'sch', 'erc', '-o', output, '--format', 'json', '--severity-all', + '--units', UNITS_2_KICAD[self._units], GS.sch_file] logger.info('- Running the ERC') run_command(cmd) # Read the result diff --git a/tests/yaml_samples/erc_no_w2_k8.kibot.yaml b/tests/yaml_samples/erc_no_w2_k8.kibot.yaml index 351ed933..ef3c97e3 100644 --- a/tests/yaml_samples/erc_no_w2_k8.kibot.yaml +++ b/tests/yaml_samples/erc_no_w2_k8.kibot.yaml @@ -4,6 +4,7 @@ kibot: global: dir: 'def_dir' + units: mils preflight: erc: